我試圖訪問應用於城堡攔截器內的方法的自定義屬性,但方法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)