Not in any signficant capacity

On Thu, Feb 5, 2009 at 11:50 PM, Andre Loker <[email protected]> wrote:

>  Thanks for your answer. The problem is that I potentially create hundreds
> of instances of the same interceptor, each with its own parameters. Wouldn't
> this bloat the container unnecessarily?
>
>  kernel.Register(Component.For<MyInterceptor>().Named
> ("myInt1").Parameters(Parameter.ForKey("key").Eq("value")));
> kernel.Register(Component.For<MyInterceptor>().Named
> ("myInt2")).Parameters(Parameter.ForKey("key").Eq("value2")));
> kernel.Register(Component.For<MyClass>().Interceptors
> (InterceptorReference.ForKey("int1"), InterceptorReference.ForKey
> ("int2"))
>
> I didn't check to see if this compiles, so no complaints =);
>
>
> On Feb 5, 11:00 am, Andre Loker <[email protected]> <[email protected]> wrote:
>
>
>  Hi everyone,
> Maybe someone can help me on this one: what I'm trying to achieve - using 
> Windsor -isto have the same interceptor type applied multiple times on the 
> same component but with different parameters.
> I can do this:
> var c = new WindsorContainer();
> c.Register(Component.For<MyClass>());
> c.Register(Component.For<MyInterceptor>().LifeStyle.Transient);
> var h = c.Kernel.GetHandler(typeof (MyClass));
> h.ComponentModel.Interceptors.Add(new 
> InterceptorReference(typeof(MyInterceptor)));
> h.ComponentModel.Interceptors.Add(new 
> InterceptorReference(typeof(MyInterceptor)));
> h.ComponentModel.Interceptors.Add(new 
> InterceptorReference(typeof(MyInterceptor)));
> // three instances of MyInterceptor are created
> var mc = c.Resolve<MyClass>();
> // each instance of the created interceptor receives one call to Intercept
> mc.DoSomething();
> But of course, no parameters are passed to the interceptors.
> Is there any built in way to pass parameters to the interceptors on creation?
> I'm not afraid of extending the Castle code if necessary, but of course I ask 
> beforehand. If a change is required, my idea is to add a dictionary to 
> InterceptorReference that holds the arguments which are passed to the 
> interceptor component on creation, just as it would be done when passing a 
> dictionary to Resolve for extra parameters. Does this sound reasonable?
> Regards,
> Andre
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to