我试图访问应用于城堡拦截器内的方法的自定义属性,但方法Attribute.GetCustomAttribute()返回null。 public class MyIntecept : Castle.DynamicProxy.IInterceptor
{
public void Intercept(IInvocation invocation)
{
// myAttr
我在我的项目中使用简单注射器。为了集成简单的喷油器与Castle.DynamicProxy我使用this example。 我有以下属性: public class MyLogAttribute : Attribute { // some code. }
public class MyTimerAttribute : Attribute { // some code. }
那么这些属性适用
ProxyGenerator generator = new ProxyGenerator();
var interceptor = new StandardInterceptor();
MyInterfaceImpl test = (MyInterfaceImpl)generator.CreateClassProxy(typeof(MyInterfaceImpl), interceptor)