Registering an Interceptor For All Interface Implementaions in Castle Windsor -


I'm quite new to the castle and especially to the Windsor using Interceptors and if it's all across a It is possible to register the interceptor, in return, instead of specifying each implementation, implementing a particular interface. For example, I have an interface called IComponent , which will be implemented by multiple classes. I have a ComponentInterceptor class written to work on these classes when they have performed a particular method, I want to do something like this:

  _container Register (Component.For & LT; IComponent & gt; () .Interceptors ("ComponentInterceptor") .LifestyleSingleton ())  

Rather than what to do:

< Pre> _container.register (Component.For & lt; IComponent & gt; (). ImplementedBy & lt; Componenta & gt; () .Interceptors ("ComponentInterceptor") .LifestyleSingleton ()), _container.Register (Component . & Lt; IComponent & gt; (.) ImplementedBy & LT; ComponentB & gt; () .Interceptors ("ComponentInterceptor") .LifestyleSingleton ())

You can register container components in the bracket via the class class . The following registers are applied to all classes in the current assembly under IComponent service IComponent and with your ComponentInterceptor Interceptor:

< pre> container.Register (Classes.FromThisAssembly () .BasedOn & LT; IComponent & gt; () .WithService.FromInterface () .Configure (c = & gt; c.Interceptors & LT; ComponentInterceptor & gt; ( )));

Other provides a bunch of examples and explains in detail how different classes are.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -