If I have defined in config:
container.Register(
Component.For<X.Y.Z.IActivityService>()
.ImplementedBy<X.Y.Z.ActivityService>()
.ServiceOverrides(ServiceOverride.ForKey("Listeners").Eq(new [] { typeof(X.Y.Z.DefaultActivityListener).FullName }))
.LifeStyle.Transient
);
and I wish to extend this configuration and add a new item to the Listeners array property such that the final configuration is effectively:
container.Register(
Component.For<X.Y.Z.IActivityService>()
.ImplementedBy<X.Y.Z.ActivityService>()
.ServiceOverrides(ServiceOverride.ForKey("Listeners").Eq(new [] { typeof(X.Y.Z.DefaultActivityListener).FullName, "MyOtherListenerID" }))
.LifeStyle.Transient
);
must I know the contents of the "array" when first registering the component, or can I retrieve the component registration and add to it?
I wish to implement my config using the decorator pattern such that I can build my container, and then extend it as needed for different scenarios. This means I need to be able to access the already configured components and add to them.
Was thinking of having a class DefaultConfig
which return the default setup and then one of more "DecoratedConfig
" classes, that would extend the default config.
So I would have
IWindsorContaner c = new DecoratedConfig(new DefaultConfig()).InitialiseContainer();
DefaultConfig
would set up the ActivityService
with a DefaultActivityListener
(as shown in example).
DecoratedConfig
would recognise that ActivityService
had been created and add its own Listener implementation to the Listeners
array on ActivityService
.
Thanks.