Considering model below:
public interface IFooBase
{
void DoSomething();
}
public interface IFoo : IFooBase
{
}
A Castle.DynamicProxy interceptor:
public class Proxy : IInterceptor
{
public void Intercept(IInvocation invocation)
{
// Here need to know from which interface the proxy
// is generate (IFooBase or IFoo).
}
}
And the proxies of IFooBase and IFoo generated using CreateInterfaceProxyWithoutTarget in the program.cs:
var generator = new ProxyGenerator();
var proxy = new Proxy();
var fooBase = generator.CreateInterfaceProxyWithoutTarget<IFooBase>(proxy);
var foo = generator.CreateInterfaceProxyWithoutTarget<IFoo>(proxy);
fooBase.DoSomething();
foo.DoSomething();
Inside the Intercept method, I need know from which interface type (IFooBase or IFoo) the proxy is generated. The only option I know is invocation.Method.DeclaringType which of course always returns FooBase type.
you can use this code i use name of interface , you can compare type of them