Nevermind, I create the instances of MyInterceptor and register those instances directly with the desired name.

To give you a glance of what I'm using it for: I'm implementing a basic(!) AOP system on top of Windsor. As of now I can e.g. do this:

// extension method that sets up the container as required
var weaver = container.EnableAop();

// register concern with inline advice
weaver.AddConcern(Concern
                    .WithPointcut(CallTo.MethodWithAttribute<LoggedAttribute>())
                    .IsAdvisedBy(call => {
                                   Console.Out.WriteLine("Before");
                                   call.Proceed();
                                   Console.Out.WriteLine("After");
                                 })
  );
// or with advice type (will be resolved from kernel)

weaver.AddConcern(Concern
                    .WithPointcut(CallTo.MethodWithAttribute<LoggedAttribute>())
                    .IsAdvisedBy<LogAdvice>()
  );

Works fine so far. It's just a basic prototype, but it might come in handy. If it turns out to be useful I'll publish the code, feedback is therefore appreciated.

Regards,
Andre

Any chance to pass non-string arguments through the component registration?

Regards,
Andre

Thanks, I'll give it a shot and see what happens!
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]> 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