【发布时间】:2019-08-14 17:14:49
【问题描述】:
我正在尝试访问应用于城堡拦截器中的方法的自定义属性,例如:
[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
}
}
}
调用方法时拦截器触发正常,但此代码未返回自定义属性。我怎样才能做到这一点?
【问题讨论】:
-
您使用的是什么版本的 DynamicProxy?
标签: c# castle-windsor interceptor castle-dynamicproxy