Component.For<IEventBus>().ImplementedBy<InProcessEventBus>().OnCreate((kernel, eventBus) => { (eventBus as InProcessEventBus).RegisterAllHandlersInAssembly(Assembly.GetAssembly(typeof(IHaveEventHandlers)), type => kernel.Resolve(type));
}
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/QdFPy_DdnQEJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
Hi Mynkow,
One way we do this is to have the InProcessEventBus have a dependency on IKernel and resolve the dependencies when we publish to the bus.
I'm not sure why you have a facility for this, facilities are use the extend de container, registrations should be done with an Installer.
Simon
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/S9D4PeYsc7AJ.
public class SearchFacility : AbstractFacility { protected override void Init() { Converter<IKernel, SearchEngine> CreateSearchEngine = kernel => { var systemSettings = kernel.Resolve<ISystemSettings>(); SearchEnvironment.SetIndexPath(systemSettings.SearchIndexLocation); return new SearchEngine(); }; Kernel.Register( Component.For<SearchEngine>().UsingFactoryMethod(CreateSearchEngine), Component.For<IFluentSearch>().ImplementedBy<FluentSearch>().LifeStyle.Transient ); } }
Can you share your facility code?
Converter<IKernel, IBus> CreateBus = kernel => {
var hanlders =ResolveHandlers(kernel); //Resolve all handlers in the kernel return new InProcessBus(hanlders);
};
Kernel.Register( Component.For<IBus>().UsingFactoryMethod(CreateBus) );
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/km1mEfmksuIJ.
Hi Mynkow
Where is the event bus registration code you were referring in your initial post in this facility?
If you want to resolve your Hanlders only once, why not you use a factory method.Converter<IKernel, IBus> CreateBus = kernel => {
var hanlders =ResolveHandlers(kernel); //Resolve all handlers in the kernel return new InProcessBus(hanlders);
};
Kernel.Register( Component.For<IBus>().UsingFactoryMethod(CreateBus) );
Put that in an installer. Just make sure you resolve the bus only once all handlers are registered.
Simon
To post to this group, send email to castle-project-users@googlegroups.com.
To unsubscribe from this group, send email to castle-project-users+unsub...@googlegroups.com.