I'm experimenting with interceptors and dynamic proxies in Ninject and I've come across a situation where I really need to 'unwrap' a proxied instance of a class to the base instance. Is this possible? It seems like it should be pretty simple but I can't find a way to do it.
This successfully calls the interceptor:
[MyInterceptorAttribute()]
public virtual int MethodCall(int input)
But then I want to find and instantiate the non-proxied versions of each class where the attribute occurs:
var methods = assembly.GetTypes()
.SelectMany(t => t.GetMethods())
.Where(m => Attribute.IsDefined(m, typeof(MyInterceptorAttribute)))
.ToList();
foreach(var method in methods) {
// The proxied instance
instance = kernel.Get(method.DeclaringType);
}
How can I get the non-proxied instance?