开发者

Solving a dependency graph for aspect oriented component

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
}

I'm trying to resolve Foo component by servi开发者_运维技巧ce IFoo but by this resolving it also implements the aspects (ICanLog, ICanCatch) given in container. Is there a solution to make real this one. (Mixin?)


You didn't attach any interceptors to IFoo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜