Is it possible to perform some custom processing when Windsor instantiates a type?
Something similar to:
container.Register(
AllTypes.Pick()
.FromAssembly(Assembly.GetExecutingAssembly())
.BasedOn<MyMarkerInterface>()
.WhenInstantiating(instance => // do some stuff with this instance)
.Configure(component => component.Startable().LifeStyle.Singleton)
.WithService.Base());
Currently we are using IStartable. Since the “Start” code (i.e. the custom processing) is identical it would be nice to move this logic out of each class.
Thanks!
Brian
You mean something like
OnCreatemethod?Singleton is default lifestyle so you don’t have to state that explicitly.
Notice however that behavior is slightly different here, as compared to how Startable facility works.
Also while the docs state that OnCreate lives in a facility, it is not true anymore (yeah, we need to update docs). This method will work out of the box.