2009-11-24 114 views
2

我一直在玩弄统一做一些AOP的东西,通过国际奥委会一样设置:团结IOC,AOP及接口拦截

ioc.RegisterType<ICustomerService, CustomerService>() 
    .Configure<Interception>().SetInterceptorFor<ICustomerService>(new InterfaceInterceptor()); 

...然后有对ICustomerService接口的方法的ICallHandler 。暂时我想要调用的方法,它所在的类以及该类的命名空间。所以......里面......

public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) 

...的ICallHandler的方法,我可以通过input.MethodBase.Name访问方法的名称...如果我使用input.MethodBase.DeclaringType.Name我获取接口ICustomerService ...但...我将如何去实现类“CustomerService”而不是接口?

我被告知要使用input.Target ..但刚刚返回“DynamicModule.ns.Wrapped_ICustomerService_4f2242e5e00640ab84e4bc9e05ba0a13”

这个人任何帮助吗?

回答

1

前段时间我尝试做类似的事情,我已经通过Unity源代码做了一些研究,唯一的解决方案是通过从input.Target私有字段反射得到CustomerService实例(我不'不要忘了它的名字,你可以很容易地在调试器中找到它)。我知道这不是一个优雅和可靠的解决方案,但看起来这是我们所能做的。