public interface IFoo : ICanCatch, ICanLog
{ void Bar () }
public class Foo : IFoo
{
public void Bar ()
{
Console.WriteLine ("Bar");
}
}
IWindsorContainer _Container;
[TestFixtureSetUp]
public void init ()
{
_Container = new WindsorContainer();
_Container.Register(
Component.For<LogInterceptor> (),
Component.For<ExceptionInterceptor> (),
Component
.For<ICanCatch>().ImplementedBy<Foo>().Interceptors<LogInterceptor>().Named ("loggableFoo"),
Component.For<ICanLog>().ImplementedBy<Foo>().Interceptors<ExceptionInterceptor>().Named ("catchableFoo"),
Component.For<IFoo>().ImplementedBy<Foo>()
);
}
[Test]
public void foo ()
{
var a = _Container.Resolve<IFoo> ();
a.Bar (); <-- Interceptors not working. IFoo is a ICanLog, ICanCatch
}
我正在尝试通过服务IFoo解析Foo组件,但通过这个解决它还实现了容器中给出的方面(ICanLog,ICanCatch)。是否有解决方案来实现这一目标。 (密新?)
答案 0 :(得分:1)
您没有将任何拦截器附加到IFoo
。