我有这样的一些方面:
public class MyAttribute : OnMethodInvocationAspect
{
public int Offset { get; internal set; }
public MyAttribute(int offset)
{
this.Offset = offset;
}
public override void OnInvocation(MethodInvocationEventArgs eventArgs)
{
//do some stuff
}
}
现在我正在上课,我将我的属性添加到它:
class MyClass
{
[MyAttribute(0x10)]
public int MyProp { get; set; }
}
一切正常。然而现在我想使用反射来获得我的偏移量;当我做
typeof(MyClass).GetProperty("MyProp").GetCustomAttributes(true);
它什么也不返回。如何访问我的原始偏移值(我的属性上的属性)?