public void Manually_triggered_start_throws_on_missing_dependencies() { var flag = new StartFlag(); Startable.Started = false; Container.AddFacility<StartableFacility>(f => f.DeferredStart(flag)); Container.Register(Component.For<Startable>()); Assert.Throws<HandlerException>(() => flag.Signal() ); }
public void Can_manually_trigger_start_only_once() { var flag = new StartFlag(); Startable.Started = false; Container.AddFacility<StartableFacility>(f => f.DeferredStart(flag)); Container.Register(Component.For<Startable>().LifestyleTransient(), Component.For<ICustomer>().ImplementedBy<CustomerImpl>()); flag.Signal(); Startable.Started = false; flag.Signal(); Assert.IsFalse(Startable.Started); }
//public static IWindsorContainer Container; public static IWindsorContainer Configure(StartFlag startFlag) { var container = new WindsorContainer(); container.AddFacility<StartableFacility>(sf => sf.DeferredStart(startFlag)); container.AddFacility<TypedFactoryFacility>(); container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, allowEmptyCollections: false)); container.Install(FromAssembly.This()); //WindsorConfig.Container = container; return container; }
public void Can_manually_trigger_start_when_using_Install() { var flag = new StartFlag(); Startable.Started = false; Container.AddFacility<StartableFacility>(f => f.DeferredStart(flag)); Container.Install( new ActionBasedInstaller(c => c.Register(Component.For<Startable>(), Component.For<ICustomer>().ImplementedBy<CustomerImpl>())) ); Assert.IsFalse(Startable.Started); flag.Signal(); Assert.IsTrue(Startable.Started); }
public void Configuration(IAppBuilder app) { var startFlag = new StartFlag(); var logger = SerilogConfig.Configure(); var container = WindsorConfig.Configure(startFlag); var jsonSettings = JsonNetConfig.Configure(GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings); SignalRConfig.Configure(container, app, jsonSettings); WebApiConfig.Configure(container, jsonSettings); MvcConfig.Configure(container); BundleConfig.Configure(); //ensure configuration of WebAPI is complete WebApiConfig.EnsureConfigured(); startFlag.Signal(); }
/// <summary> /// Startable components will be started when <see cref = "StartFlag.Signal" /> method is invoked. This is particularily usedul when you need to perform some extra initialization outside of container /// before starting the Startable components. /// </summary> public void DeferredStart(StartFlag flag) { this.flag = flag; }