public static void Registrate() { var container = new WindsorContainer(); var dataLayerAssemblyName = "EndowmentDataLayer"; var dataLayerNameEndComponents = new[] { "Factory", "Handler" }; var dataLayerNameContains = new[] { "Endowment" }; var webAppAssemblyName = "EndowmentWebApp"; var webAppNameEndComponents = new[] { "Builder", "Service" }; var webAppNamespaceContainComponents = new[] { "Infrastructure" }; var windsorCommonInstaller = new WindsorCommonInstaller(); windsorCommonInstaller .NameEndWith(dataLayerAssemblyName, dataLayerNameEndComponents) .NameContains(dataLayerAssemblyName, dataLayerNameContains) .NameEndWith(webAppAssemblyName, webAppNameEndComponents) .NamespaceContains(webAppAssemblyName, webAppNamespaceContainComponents); var windsorInstallers = windsorCommonInstaller.GetInstallers().ToList(); var listInstaller = new List<IWindsorInstaller> { new InfrastructureProjectWindsorInstaller(), new RepositorySingletonInstaller(ActivatorDbForWindsor.TypeOfEntity, typeof (TestEndowmentRepository)), new WindsorInstallerTestClasses() }; windsorInstallers.AddRange(listInstaller); container.Install(windsorInstallers.ToArray()); }
public static void Register() { var container = new WindsorContainer(); const string dataLayerAssemblyName = "EndowmentDataLayer"; var dataLayerNameEndComponents = new []{"Factory", "Handler" }; var dataLayerNameContains = new[] { "Endowment"}; const string thisAssemblyName = "EndowmentWebApp"; var thisNameEndComponents = new[] {"Builder", "Service"}; var thisNamespaceContainComponents = new[] {"Infrastructure"}; ActivatorDbForWindsor.AddEndowmentContext(); var windsorCommonInstaller = new WindsorCommonInstaller(); windsorCommonInstaller .NameEndWith(dataLayerAssemblyName, dataLayerNameEndComponents) .NameContains(dataLayerAssemblyName, dataLayerNameContains) .NameEndWith(thisAssemblyName, thisNameEndComponents) .NamespaceContains(thisAssemblyName, thisNamespaceContainComponents); var windsorInstallers = windsorCommonInstaller.GetInstallers().ToList(); // вынесены в отдельную регистрацию var listInstaller = new List<IWindsorInstaller> { new InfrastructureProjectWindsorInstaller(), // самодостаточный инсталлер new RepositorySingletonInstaller(ActivatorDbForWindsor.TypeOfEntity, ActivatorDbForWindsor.EndowmentRepositoryType), // много абстракции, автоматическая регистрация не удается new ControllerInstaller(thisAssemblyName), // дефолтная регистрация как синглтон, для контроллеров не подходит new ControllerFactoryInstaller() // заменяет фабрику контроллеров, также самодостааточная }; windsorInstallers.AddRange(listInstaller); container.Install(windsorInstallers.ToArray()); }