public void Install(IWindsorContainer container, IConfigurationStore store) { var hubs = new List <Type>(); foreach (Assembly assembly in _assemblies) { container.Register( Classes.FromAssembly(assembly) .BasedOn <IHub>() .Unless(x => { if (_removeHubs.Contains(x)) { return(true); } hubs.Add(x); return(false); }) .WithServiceSelf() .LifestyleTransient()); container.Register( Classes.FromAssembly(assembly) .BasedOn <IHubPipelineModule>() .Unless(_removePipelines.Contains) .WithService.FromInterface()); } IWindsorInstaller installer = Installer .Instance <IHubsProvider>(new SignalRHubs(hubs.ToArray())); container.Install(installer); }
/// <summary> /// Registers a one or another service implementation depending on whether the IntegrationDb is disabled or not. /// </summary> /// <typeparam name="TService"></typeparam> /// <param name="integrationDbEnabledInstance">The service implementation instance to use when we have an IntegrationDb available.</param> /// <param name="integrationDbDisabledInstance">The (fallback) service implementation instance to use when IntegrationDb is disabled.</param> public ServicesAdvancedConfiguration Register <TService>(Func <IKernel, TService> integrationDbEnabledInstance, Func <IKernel, TService> integrationDbDisabledInstance) where TService : class { if (integrationDbEnabledInstance == null) { throw new ArgumentNullException(nameof(integrationDbEnabledInstance)); } if (integrationDbDisabledInstance == null) { throw new ArgumentNullException(nameof(integrationDbDisabledInstance)); } _registrations[typeof(TService)] = new Registration( kernel => Installer.Instance(integrationDbEnabledInstance(kernel)), kernel => Installer.Instance(integrationDbDisabledInstance(kernel))); return(this); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( Component.For <IHttpServerFactory>() .UsingFactoryMethod((kernel, model, context) => new HttpServerFactory(kernel, _httpServerConfiguration)) .LifestyleSingleton()); var types = new List <Type>(); foreach (Assembly assembly in _scanAssemblies.Distinct()) { container.Register( Classes.FromAssembly(assembly) .BasedOn <ApiController>() .Unless(x => { if (_removeControllers.Contains(x)) { return(true); } types.Add(x); return(false); }) .WithServiceSelf() .LifestyleScoped()); } container.Register( Classes.From(_addControllers.Except(_removeControllers).Distinct()) .BasedOn <ApiController>() .Expose(types.Add) .WithServiceSelf() .LifestyleScoped()); IWindsorInstaller installer = Installer .Instance <IWebApiControllers>(new ControllerTypes(types.ToArray())); container.Install(installer); }