2010-10-15 6 views
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 
} 

Je suis en train de résoudre le composant Foo par IFoo service, mais par cette résolution, il met également en œuvre les aspects (ICanLog, ICanCatch) donnés dans le récipient. Y at-il une solution pour rendre réel celui-ci. (Mixin?)Résoudre un graphe de dépendance pour le composant orienté aspect

Répondre

1

Vous n'avez associé aucun intercepteur à IFoo.

Questions connexes