1
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)。有没有办法让这个成为现实。(混音?)

4

1 回答 1

1

您没有将任何拦截器附加到IFoo.

于 2010-10-15T06:37:19.307 回答