我試圖城堡攔截器中訪問應用的方法的自定義屬性,如:訪問自定義屬性
[MyCustomAttribute(SomeParam = "attributeValue")]
public virtual MyEntity Entity { get; set; }
使用下面的代碼:
internal class MyInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
if (invocation.Method.GetCustomAttributes(typeof(MyCustomAttribute), true) != null)
{
//Do something
}
}
}
攔截器在調用方法時觸發OK,但此代碼不返回自定義屬性。我怎樣才能做到這一點?
您使用的是什麼版本DynamicProxy的? – 2010-03-29 14:12:41
我正在使用版本2.1 – 2010-03-29 16:34:03