Unity IOC, AOP & Interface Interception

Posted by krisg on Stack Overflow See other posts from Stack Overflow or by krisg
Published on 2009-11-24T12:33:01Z Indexed on 2010/05/18 5:50 UTC
Read the original article Hit count: 596

Filed under:
|
|
|
|

I've been playing around with Unity to do some AOP stuff, setting up via IOC like:

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

... and then having an ICallHandler on the ICustomerService interface's methods. For teh time being i want to just get the method called, the class it's in, and the namespace for that class. So... inside the...

public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)

...method of the ICallHandler, i can access the method name via input.MethodBase.Name... if i use input.MethodBase.DeclaringType.Name i get the interface ICustomerService... BUT... how would i go about getting the implementing class "CustomerService" rather than the interface?

I've been told to use input.Target.. but that just returns "DynamicModule.ns.Wrapped_ICustomerService_4f2242e5e00640ab84e4bc9e05ba0a13"

Any help on this folks?

© Stack Overflow or respective owner

Related posts about unity

Related posts about aop