private static void InstallHavitEntityFramework(IWindsorContainer container, InstallConfiguration configuration)
 {
     container.WithEntityPatternsInstaller(new ComponentRegistrationOptions {
         GeneralLifestyle = configuration.ScopedLifestyle
     })
     .RegisterEntityPatterns()
     //.RegisterLocalizationServices<Language>()
     .RegisterDbContext <DistillerDbContext>(new DbContextOptionsBuilder <DistillerDbContext>().UseSqlServer(configuration.DatabaseConnectionString).Options)
     .RegisterDataLayer(typeof(ILoginAccountDataSource).Assembly);
 }
        public static IWindsorContainer ConfigureForWebAPI(this IWindsorContainer container, IConfiguration configuration)
        {
            InstallConfiguration installConfiguration = new InstallConfiguration
            {
                DatabaseConnectionString = configuration.GetConnectionString("Database"),
                ServiceProfiles          = new[] { ServiceAttribute.DefaultProfile, ServiceProfiles.WebAPI },
                ScopedLifestyle          = lf => lf.PerAspNetCoreRequest()
            };

            return(container.ConfigureForAll(installConfiguration));
        }
        public static IWindsorContainer ConfigureForTests(this IWindsorContainer container)
        {
            string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            if (string.IsNullOrEmpty(environment))
            {
                environment = "Development";
            }

            IConfigurationRoot configuration = new ConfigurationBuilder()
                                               .SetBasePath(Directory.GetCurrentDirectory())
                                               .AddJsonFile("appsettings.json")
                                               .AddJsonFile($"appsettings.{environment}.json", true)
                                               .Build();

            InstallConfiguration installConfiguration = new InstallConfiguration
            {
                DatabaseConnectionString = configuration.GetConnectionString("Database"),
                ServiceProfiles          = new[] { ServiceAttribute.DefaultProfile },
                ScopedLifestyle          = lf => lf.PerThread,
            };

            return(container.ConfigureForAll(installConfiguration));
        }
        private static IWindsorContainer ConfigureForAll(this IWindsorContainer container, InstallConfiguration installConfiguration)
        {
            // umožní resolvovat i kolekce závislostí - IEnumerable<IDependency>
            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));

            // facilities
            container.AddFacility <TypedFactoryFacility>();
            container.Register(Component.For(typeof(IServiceFactory <>)).AsFactory());

            InstallHavitEntityFramework(container, installConfiguration);
            InstallHavitServices(container);
            InstallByServiceAttribute(container, installConfiguration);
            InstallAuthorizationHandlers(container, installConfiguration);

            return(container);
        }
 private static void InstallAuthorizationHandlers(IWindsorContainer container, InstallConfiguration installConfiguration)
 {
     container.Register(Classes.FromAssembly(typeof(Havit.Distiller.Services.Properties.AssemblyInfo).Assembly)
                        .BasedOn <IAuthorizationHandler>()
                        .WithService.FromInterface(typeof(IAuthorizationHandler))
                        .Configure(configurer => installConfiguration.ScopedLifestyle(configurer.LifeStyle))
                        );
 }
 private static void InstallByServiceAttribute(IWindsorContainer container, InstallConfiguration configuration)
 {
     container.InstallByServiceAttibute(typeof(Havit.Distiller.DataLayer.Properties.AssemblyInfo).Assembly, configuration.ServiceProfiles, configuration.ScopedLifestyle);
     container.InstallByServiceAttibute(typeof(Havit.Distiller.Services.Properties.AssemblyInfo).Assembly, configuration.ServiceProfiles, configuration.ScopedLifestyle);
     container.InstallByServiceAttibute(typeof(Havit.Distiller.Facades.Properties.AssemblyInfo).Assembly, configuration.ServiceProfiles, configuration.ScopedLifestyle);
 }