let's think of an Interface like this:
public interface ITest
{
void DoSomething();
}
I don't want to implement this interface, and ask Ninject to generate a proxy class implementing it. Then Intercept DoSomething method. Is it possible?
let's think of an Interface like this:
public interface ITest
{
void DoSomething();
}
I don't want to implement this interface, and ask Ninject to generate a proxy class implementing it. Then Intercept DoSomething method. Is it possible?
As far as i know, out of the box ninject does not support interception proxies without an implementation (i.E. class inheriting from the interface). If you want an interface proxy with implementation only by interceptors, no class, then you could use castle.dynamicproxy "interface proxy without target" (see http://docs.castleproject.org/Tools.Kinds-of-proxy-objects.ashx), but you would have to implement the binding sugar yourself.
Alternatively you could try to use https://github.com/ninject/ninject.extensions.interception and .Bind().ToConstant(Mock.Of).Intercept().With(new SomeInterceptor);.
kernel.Bind(typeof(ITest)).To(typeof(Class1)).Intercept().With((IInterceptor)new MyInterceptor());
Class1 is an empty class and MyInterceptor must implement IInterceptor interface. – themehrdad Nov 27 '13 at 10:24