0
이벤트에서 사용자 지정 특성을 가져올 수 있습니까? C# 이벤트에서 사용자 지정 특성 가져 오기
public class TestClass
{
[Test()]
public event EventHandler TestEvent;
public void RunTest()
{
//Get attributes from TestEvent
}
}
[AttributeUsage(AttributeTargets.Event)]
public class TestAttribute : Attribute
{
}
나는 다음과 같은 시도했지만 모두 어떤 결과를 산출하지 :
Console.WriteLine("Attr: {0}", Attribute.GetCustomAttribute(TestEvent.GetMethodInfo(), typeof (TestAttribute)) != null);
Console.WriteLine("Attr: {0}", Attribute.GetCustomAttribute(TestEvent.Method, typeof (TestAttribute)) != null);