views:

24

answers:

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
}

I'm trying to resolve Foo component by service 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?)

A: 

You didn't attach any interceptors to IFoo.

Krzysztof Koźmic

related questions