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);
        }
Beispiel #2
0
        /// <summary>
        /// Registers a one or another service implementation depending on whether the IntegrationDb is disabled or not.
        /// </summary>
        /// <typeparam name="TService">The common service interface shared by the implementations.</typeparam>
        /// <typeparam name="TIntegrationDbEnabledImpl">The service implementation to use when we have an IntegrationDb available.</typeparam>
        /// <typeparam name="TIntegrationDbDisabledImpl">The (fallback) service implementation to use when IntegrationDb is disabled.</typeparam>
        public ServicesAdvancedConfiguration Register <TService, TIntegrationDbEnabledImpl, TIntegrationDbDisabledImpl>()
            where TService : class
            where TIntegrationDbEnabledImpl : class, TService
            where TIntegrationDbDisabledImpl : class, TService
        {
            // TODO: Test at denne også erstatter en service som er registreret by convention
            // TODO: Giv mulighed for at påvirke Registration / Singleton / ala public InstanceInstaller(T instance, Action<ComponentRegistration<T>> registration = null)

            _registrations[typeof(TService)] = new Registration(
                kernel => Installer.Service <TService, TIntegrationDbEnabledImpl>(),
                kernel => Installer.Service <TService, TIntegrationDbDisabledImpl>());

            return(this);
        }
Beispiel #3
0
        /// <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);
        }