2009-11-24 76 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實例(我不'不要忘了它的名字,你可以很容易地在調試器中找到它)。我知道這不是一個優雅和可靠的解決方案,但看起來這是我們所能做的。