public CastleJobFactory() { _Container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle"))); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _Container.Register(AllTypes.FromAssemblyInDirectory(new AssemblyFilter(path)).BasedOn <IJob>().Configure(c => c.LifeStyle.Is(LifestyleType.Transient))); }
public void Install(IWindsorContainer container, IConfigurationStore store) { var allTypesFromBinDir = AllTypes.FromAssemblyInDirectory(new AssemblyFilter(HttpRuntime.BinDirectory)); container.Register(allTypesFromBinDir .BasedOn <IComponentService>() .WithService.FromInterface()); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register(AllTypes.FromThisAssembly().BasedOn <IApplicationService>().WithServiceFirstInterface()); container.Register( AllTypes.FromAssemblyInDirectory(new AssemblyFilter(AppDomain.CurrentDomain.BaseDirectory, "QuadAuto.Server.*.dll")) .BasedOn <IApplicationService>().WithServiceFirstInterface()); }
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { container.Register( AllTypes.FromAssemblyInDirectory(new KeyHubApplicationAssemblyFilter()) .BasedOn <IKernelEvent>() .WithService.FirstInterface() .LifestyleTransient()); container.Register(Component.For <IKernelContext>().ImplementedBy <KernelContext>().LifestyleSingleton()); }
/// <summary> /// Performs the installation in the <see cref="T:Castle.Windsor.IWindsorContainer"/>. /// </summary> /// <param name="container">The container.</param> /// <param name="store">The configuration store.</param> public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { var conventions = container.Resolve <BootstrapConventions>(); var currentDirectory = Helpers.EnvironmentHelper.GetCurrentDirectory(); container.Register ( AllTypes.FromAssemblyInDirectory(new AssemblyFilter(currentDirectory).FilterByAssembly(conventions.IncludeAssemblyInContainerScan)) .IncludeNonPublicTypes() .Where(t => conventions.IsViewModel(t) && !conventions.IsExcluded(t)) .WithService.Select((type, baseTypes) => conventions.SelectViewModelContracts(type)) .Configure(r => { r.PropertiesIgnore(conventions.IgnoreViewModelPropertyInjection); var services = this.GetServices(r); if (conventions.IsShellViewModel(services, r.Implementation)) { r.LifeStyle.Is(LifestyleType.Singleton); } else { r.LifeStyle.Is(LifestyleType.Transient); } }) ); container.Register ( AllTypes.FromAssemblyInDirectory(new AssemblyFilter(currentDirectory).FilterByAssembly(conventions.IncludeAssemblyInContainerScan)) .IncludeNonPublicTypes() .Where(t => conventions.IsView(t) && !conventions.IsExcluded(t)) .WithService.Select((type, baseTypes) => conventions.SelectViewContracts(type)) .Configure(r => { r.PropertiesIgnore(conventions.IgnoreViewPropertyInjection); var services = this.GetServices(r); if (conventions.IsShellView(services, r.Implementation)) { r.LifeStyle.Is(LifestyleType.Singleton); } else { r.LifeStyle.Is(LifestyleType.Transient); } }) ); }
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { container.Register( AllTypes.FromAssemblyInDirectory(new KeyHubApplicationAssemblyFilter()) .BasedOn <IBusinessRule>() .WithService.AllInterfaces() .LifestyleTransient()); container.Register( Component.For <IBusinessRuleExecutor>().ImplementedBy <BusinessRuleExecutor>().LifestyleTransient()); container.Register(Component.For <IBusinessRuleExecutorFactory>().AsFactory()); }
public void RegisterDirectoryAssemblyTypes_BasedOn_RegisteredInContainer() { var directory = AppDomain.CurrentDomain.BaseDirectory; Kernel.Register(AllTypes.FromAssemblyInDirectory(new AssemblyFilter(directory)) .BasedOn <ICommon>()); var handlers = Kernel.GetHandlers(typeof(ICommon)); Assert.AreEqual(0, handlers.Length); handlers = Kernel.GetAssignableHandlers(typeof(ICommon)); Assert.AreNotEqual(0, handlers.Length); }
/// <summary> /// Performs the installation in the <see cref="T:Castle.Windsor.IWindsorContainer"/>. /// </summary> /// <param name="container">The container.</param> /// <param name="store">The configuration store.</param> public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { var conventions = container.Resolve <BootstrapConventions>(); var currentDirectory = Helpers.EnvironmentHelper.GetCurrentDirectory(); // Registriamo gli handler container.Register ( AllTypes.FromAssemblyInDirectory(new AssemblyFilter(currentDirectory).FilterByAssembly(conventions.IncludeAssemblyInContainerScan)) .IncludeNonPublicTypes() .Where(t => conventions.IsMessageHandler(t) && !conventions.IsExcluded(t)) .WithService.Select((type, baseTypes) => conventions.SelectMessageHandlerContracts(type)) .Configure(c => c.PropertiesIgnore(conventions.IgnorePropertyInjection)) ); }
protected override void Init() { var filter = new AssemblyFilter(AppDomain.CurrentDomain.BaseDirectory, "QuadAuto.Server.*.dll"); var x = AllTypes.FromAssemblyInDirectory(filter).BasedOn <IConsumer>().WithServiceSelect( (t, b) => new[] { t, typeof(IConsumer) }); Kernel.Register(x); var y = AllTypes.FromThisAssembly().BasedOn <IConsumer>().WithServiceSelect( (t, b) => new[] { t, typeof(IConsumer) }); Kernel.Register(y); Kernel.Register(Component.For <IServiceBus>().UsingFactoryMethod(ConfigureServiceBus)); }
public IWindsorContainer Run() { var documentStore = new DocumentStore { Url = "http://localhost:8080/", DefaultDatabase = "EventStore" }; documentStore.Initialize(); var container = new WindsorContainer(); var eventBus = new MsmqEventBus(); container.Register( Component.For <IWindsorContainer>().Instance(container), Component.For <IDocumentStore>().Instance(documentStore), Component.For <IEventBus>().Instance(eventBus), Component.For(typeof(IRepository <>)).ImplementedBy(typeof(RavenDbRepository <>)).LifeStyle.Transient, Component.For <ICommandProcessor>().ImplementedBy <CommandProcessor>(), AllTypes.FromAssemblyInDirectory(new AssemblyFilter(".\\")).BasedOn(typeof(ICommandHandler <>)).Configure(registration => registration.LifestyleTransient()).WithService.AllInterfaces() ); return(container); }