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 に答える