public void AddComponent_ServiceOverrides_WorksFine() { Kernel.Register( Component.For <ICustomer>() .Named("customer1") .ImplementedBy <CustomerImpl>() .DependsOn( Property.ForKey("Name").Eq("Caption Hook"), Property.ForKey("Address").Eq("Fairyland"), Property.ForKey("Age").Eq(45) ), Component.For <CustomerChain1>() .Named("customer2") .DependsOn( Property.ForKey("Name").Eq("Bigfoot"), Property.ForKey("Address").Eq("Forest"), Property.ForKey("Age").Eq(100) ) .DependsOn( ServiceOverride.ForKey("customer").Eq("customer1") ) ); var customer = Kernel.Resolve <CustomerChain1>("customer2"); Assert.IsNotNull(customer.CustomerBase); Assert.AreEqual(customer.CustomerBase.Name, "Caption Hook"); Assert.AreEqual(customer.CustomerBase.Address, "Fairyland"); Assert.AreEqual(customer.CustomerBase.Age, 45); }
public void AddComponent_ArrayServiceOverrides_WorksFine() { Kernel.Register( Component.For <ICommon>() .Named("common1") .ImplementedBy <CommonImpl1>(), Component.For <ICommon>() .Named("common2") .ImplementedBy <CommonImpl2>(), Component.For <ClassWithArrayConstructor>() .DependsOn( ServiceOverride.ForKey("first").Eq("common2"), ServiceOverride.ForKey("services").Eq("common1", "common2") ) ); var common1 = Kernel.Resolve <ICommon>("common1"); var common2 = Kernel.Resolve <ICommon>("common2"); var component = Kernel.Resolve <ClassWithArrayConstructor>(); Assert.AreSame(common2, component.First); Assert.AreEqual(2, component.Services.Length); Assert.AreSame(common1, component.Services[0]); Assert.AreSame(common2, component.Services[1]); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Kernel.ComponentRegistered += Kernel_ComponentRegistered; container.AddFacility(new PersistenceFacility()); container.Register( // Unit of Work Component.For <NHUnitOfWorkInterceptor>().LifeStyle.Transient, // Repositórios Classes.FromAssembly(Assembly.GetAssembly(typeof(UsuarioRepository))) .InSameNamespaceAs <UsuarioRepository>() .WithService.DefaultInterfaces() .Configure(c => { c.DependsOn(ServiceOverride.ForKey <ISession>().Eq(DBCONFIGCONNECT)); }) .LifestyleTransient(), Classes.FromAssembly(Assembly.GetAssembly(typeof(ParticipanteRepository))) .InSameNamespaceAs <ParticipanteRepository>() .WithService.DefaultInterfaces() .Configure(c => { c.DependsOn(ServiceOverride.ForKey <ISession>().Eq(DBBUSINESSCONNECT)); }) .LifestyleTransient(), // Serviços Classes.FromAssembly(Assembly.GetAssembly(typeof(UsuarioService))).InSameNamespaceAs <UsuarioService>().WithService.DefaultInterfaces().LifestyleTransient(), Classes.FromAssembly(Assembly.GetAssembly(typeof(ParticipanteService))).InSameNamespaceAs <ParticipanteService>().WithService.DefaultInterfaces().LifestyleTransient(), //All MVC controllers Classes.FromThisAssembly().BasedOn <IController>().LifestyleTransient() ); }
public void Collection_should_be_resolvable_normally_service_override_named() { Container.AddFacility <FactorySupportFacility>(); Container.Register(Component.For <IEnumerable <IEmptyService> >().Named("foo") .UsingFactoryMethod(() => new IEmptyService[] { new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA(), new EmptyServiceA() }), Component.For <EnumerableDepAsConstructor>() .DependsOn(ServiceOverride .ForKey <IEnumerable <IEmptyService> >() .Eq("foo"))); var collection = Container.Resolve <IEnumerable <IEmptyService> >(); Assert.AreEqual(10, collection.Count()); var service = Container.Resolve <EnumerableDepAsConstructor>(); Assert.AreEqual(10, service.Services.Count()); }
/// <summary> /// Registers a new core in the container. /// This method is meant to be used after the facility initialization /// </summary> /// <param name="core"></param> private void RegisterCore(SolrCore core) { var coreConnectionId = core.Id + typeof(SolrConnection); Kernel.Register(Component.For <ISolrConnection>().ImplementedBy <SolrConnection>() .Named(coreConnectionId) .Parameters(Parameter.ForKey("serverURL").Eq(core.Url))); var ISolrQueryExecuter = typeof(ISolrQueryExecuter <>).MakeGenericType(core.DocumentType); var SolrQueryExecuter = typeof(SolrQueryExecuter <>).MakeGenericType(core.DocumentType); Kernel.Register(Component.For(ISolrQueryExecuter).ImplementedBy(SolrQueryExecuter) .Named(core.Id + SolrQueryExecuter) .ServiceOverrides(ServiceOverride.ForKey("connection").Eq(coreConnectionId))); var ISolrBasicOperations = typeof(ISolrBasicOperations <>).MakeGenericType(core.DocumentType); var ISolrBasicReadOnlyOperations = typeof(ISolrBasicReadOnlyOperations <>).MakeGenericType(core.DocumentType); var SolrBasicServer = typeof(SolrBasicServer <>).MakeGenericType(core.DocumentType); Kernel.Register(Component.For(ISolrBasicOperations, ISolrBasicReadOnlyOperations) .ImplementedBy(SolrBasicServer) .Named(core.Id + SolrBasicServer) .ServiceOverrides(ServiceOverride.ForKey("connection").Eq(coreConnectionId), ServiceOverride.ForKey("queryExecuter").Eq(core.Id + SolrQueryExecuter))); var ISolrOperations = typeof(ISolrOperations <>).MakeGenericType(core.DocumentType); var SolrServer = typeof(SolrServer <>).MakeGenericType(core.DocumentType); Kernel.Register(Component.For(ISolrOperations).ImplementedBy(SolrServer) .Named(core.Id) .ServiceOverrides(ServiceOverride.ForKey("basicServer").Eq(core.Id + SolrBasicServer))); }
/// <summary> /// Extend the given component registration with service dependency information from attributes. /// </summary> private static ComponentRegistration <object> SetupNamedDependencies(ComponentRegistration <object> registration, Type c) { var attrs = c.GetCustomAttributes(typeof(DependsOn), true); var namedDependencyAttrs = attrs.Select(o => (DependsOn)o); namedDependencyAttrs.ForEach(d => registration = registration.DependsOn(ServiceOverride.ForKey(d.ServiceType).Eq(d.Name))); return(registration); }
static void Main(string[] cmdline) { // Parse commandline into Arguments var argsModelDef = Args.Configuration.Configure <Arguments>(); Arguments args = new Arguments(); try { Args.Configuration.Configure <Arguments>().BindModel(args, cmdline); } catch (Exception) { args.Help = true; } // Write help message if (args.Help == true) { var modelHelp = new Args.Help.HelpProvider().GenerateModelHelp(argsModelDef); new Args.Help.Formatters.ConsoleHelpFormatter().WriteHelp(modelHelp, Console.Out); return; } // Setup and run client using (WindsorContainer container = new WindsorContainer()) { Logger.Configure(x => x.UseNLogLogger()); container.AddFacility <LoggingFacility>(f => f.LogUsing(LoggerImplementation.NLog)); switch (args.Transport.ToLowerInvariant()) { case "wcf": container.Install(new WcfClientInstaller()); break; case "masstransit": container.Install(new MasstransitClientInstaller()); break; default: Console.WriteLine("Supported transports are Wcf and Masstransit"); return; } container.Register( Component.For <IAssemblyRepository>().Named("Caching").ImplementedBy <CachingAssemblyRepository>().LifestyleSingleton() .DependsOn(new { TTL = TimeSpan.FromSeconds(args.TTL) }), Component.For <Client>().ImplementedBy <Client>().LifestyleTransient() .DependsOn(args.Caching ? ServiceOverride.ForKey <IAssemblyRepository>().Eq("Caching") : null) ); Client client = container.Resolve <Client>(); client.Run(); } }
public void Typed_arguments_work_for_closed_generic_ServiceOverrides() { Kernel.Register(Component.For <IGeneric <string> >().ImplementedBy <GenericImpl1 <string> >().Named("default"), Component.For <IGeneric <string> >().ImplementedBy <GenericImpl2 <string> >().Named("non-default"), Component.For <UsesIGeneric <string> >().DependsOn(ServiceOverride.ForKey <IGeneric <string> >().Eq("non-default"))); var item = Kernel.Resolve <UsesIGeneric <string> >(); Assert.IsInstanceOf <GenericImpl2 <string> >(item.Dependency); }
public void Typed_arguments_work_for_ServiceOverrides() { Kernel.Register(Component.For <ICommon>().ImplementedBy <CommonImpl1>().Named("default")); Kernel.Register(Component.For <ICommon>().ImplementedBy <CommonImpl2>().Named("non-default")); Kernel.Register(Component.For <CommonServiceUser>().DependsOn(ServiceOverride.ForKey <ICommon>().Eq("non-default"))); var item = Kernel.Resolve <CommonServiceUser>(); Assert.IsInstanceOf <CommonImpl2>(item.CommonService); }
public void Typed_arguments_work_for_open_generic_ServiceOverrides_open_service() { Kernel.Register(Component.For(typeof(IGeneric <>)).ImplementedBy(typeof(GenericImpl1 <>)).Named("default")); Kernel.Register(Component.For(typeof(IGeneric <>)).ImplementedBy(typeof(GenericImpl2 <>)).Named("non-default")); Kernel.Register(Component.For(typeof(UsesIGeneric <>)) .ServiceOverrides(ServiceOverride.ForKey(typeof(IGeneric <>)).Eq("non-default"))); var item = Kernel.Resolve <UsesIGeneric <string> >(); Assert.IsInstanceOf <GenericImpl2 <string> >(item.Dependency); }
public void Service_override_by_name_is_case_insensitive() { Kernel.Register(Component.For <DefaultSpamServiceWithConstructor>().Named("spamService")); Kernel.Register(Component.For <DefaultMailSenderService>().Named("someMailSender")); Kernel.Register(Component.For <DefaultTemplateEngine>().Named("templateEngine") .DependsOn(ServiceOverride.ForKey("mailSENDER").Eq("SOMEmailSenDeR"))); var spamservice = Kernel.Resolve <DefaultSpamServiceWithConstructor>("spamSERVICE"); Assert.IsNotNull(spamservice); Assert.IsNotNull(spamservice.MailSender); Assert.IsNotNull(spamservice.TemplateEngine); }
public void Configure(AbstractRhinoServiceBusFacility facility, IConfiguration configuration) { var kernel = facility.Kernel; var security = configuration.Children["security"]; if (security == null) { kernel.Register( Component.For <IValueConvertor <WireEcryptedString> >() .ImplementedBy <ThrowingWireEcryptedStringConvertor>() ); kernel.Register( Component.For <IElementSerializationBehavior>() .ImplementedBy <ThrowingWireEncryptedMessageConvertor>() ); return; } var key = security.Children["key"]; if (key == null || string.IsNullOrEmpty(key.Value)) { throw new ConfigurationErrorsException("<security> element must have a <key> element with content"); } var keyBuffer = Convert.FromBase64String(key.Value); kernel.Register( Component.For <IEncryptionService>() .ImplementedBy <RijndaelEncryptionService>() .DependsOn(new { key = keyBuffer, }) .Named("esb.security") ); kernel.Register( Component.For <IValueConvertor <WireEcryptedString> >() .ImplementedBy <WireEcryptedStringConvertor>() .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security")) ); kernel.Register( Component.For <IElementSerializationBehavior>() .ImplementedBy <WireEncryptedMessageConvertor>() .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security")) ); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( Component.For <IOutputWriter>() .ImplementedBy <OutputWritter>() .Named("outputWriter"), Component.For <IDataBaseWritter>() .ImplementedBy <DataBaseWritter>() .Named("dataBaseWritter"), Component.For <IFileWritter>() .ImplementedBy <FileWritter>() .Named("fileWritter"), Component.For <IJobLogger>() .ImplementedBy <ConsoleJobLogger>() .DependsOn(ServiceOverride.ForKey <IOutputWriter>().Eq("outputWriter")) .Named("consoleJobLogger"), Component.For <IJobLogger>() .ImplementedBy <DatabaseJobLogger>() .DependsOn(ServiceOverride.ForKey <IDataBaseWritter>().Eq("dataBaseWritter")) .Named("databaseJobLogger"), Component.For <IJobLogger>() .ImplementedBy <FileJobLogger>() .DependsOn(ServiceOverride.ForKey <IFileWritter>().Eq("fileWritter")) .Named("fileJobLogger"), Component.For <JobLoggerFactory>() .DependsOn( ServiceOverride.ForKey("consoleLogger").Eq("consoleJobLogger"), ServiceOverride.ForKey("databaseLogger").Eq("databaseJobLogger"), ServiceOverride.ForKey("fileLogger").Eq("fileJobLogger") ).Named("jobLoggerFactory"), Component.For <MessageFactory>(), Component.For <JobLogger>().Named("jobLogger"), Component.For <JobLoggerBuilder>() .DependsOn( ServiceOverride.ForKey("jobLogger").Eq("jobLogger"), ServiceOverride.ForKey("loggerFactory").Eq("jobLoggerFactory") ) ); }
public void Setup() { _container = new WindsorContainer(); _container.Register(Component.For <IEngine>().ImplementedBy <BMWI6Engine>().ServiceOverrides( ServiceOverride.ForKey("fuelType").Eq("90")).Named("BMWEngine")); _container.Register(Component.For <IEngine>().ImplementedBy <HondaV6Engine>().ServiceOverrides( ServiceOverride.ForKey("fuelType").Eq("87")).Named("HondaEngine")); _container.Register(Component.For <IFuelType>().ImplementedBy <FuelType90>().Named("90")); _container.Register(Component.For <IFuelType>().ImplementedBy <FuelType87>().Named("87")); _container.Register(Component.For <IMyCar>().ImplementedBy <MyCar>().ServiceOverrides( ServiceOverride.ForKey("engine").Eq("HondaEngine"))); _myCar = _container.Resolve <IMyCar>(); }
public void Two_satisfiable_constructors_equal_number_of_inline_parameters_pick_one_with_more_service_overrides() { Container.Register(Component.For <ICommon>().ImplementedBy <CommonImpl1>().Named("Mucha"), Component.For <ICustomer>().ImplementedBy <CustomerImpl>().Named("Stefan"), Component.For <HasTwoConstructors>().Named("first") .DependsOn(ServiceOverride.ForKey("customer").Eq("Stefan")), Component.For <HasTwoConstructors>().Named("second") .DependsOn(ServiceOverride.ForKey("common").Eq("Mucha"))); var first = Container.Resolve <HasTwoConstructors>("first"); var second = Container.Resolve <HasTwoConstructors>("second"); Assert.IsNotNull(first.Customer); Assert.IsNotNull(second.Common); }
public void Resolving_Named_Component_With_ServiceOverride() { var collection = new ServiceCollection(); var serviceProvider = CreateServiceProvider(collection); var windsorContainer = serviceProvider.GetService <IWindsorContainer>(); windsorContainer.Register( Component.For <MyTestClass3>().Named("CustomTestClass"), Component.For <MyTestClass2>().ImplementedBy <MyTestClass2>() .DependsOn(ServiceOverride.ForKey("myTestClass3").Eq("CustomTestClass")) ); var test1 = serviceProvider.GetService <MyTestClass2>(); Assert.NotNull(test1); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( Component.For <IEmptyService>().ImplementedBy <EmptyServiceA>().Named("foo"), Component.For <IEmptyService>().ImplementedBy <EmptyServiceB>().Named("bar"), Component.For <IEmptyService>().ImplementedBy <EmptyServiceDecoratorViaProperty>().Named("baz"), Component.For <ArrayDepAsConstructor>().Named("InjectAll"), Component.For <ArrayDepAsConstructor>().Named("InjectFooOnly") .DependsOn(ServiceOverride.ForKey("services").Eq(new[] { "foo" })), Component.For <ArrayDepAsConstructor>().Named("InjectFooAndBarOnly") .DependsOn(ServiceOverride.ForKey("services").Eq(new[] { "foo", "bar" })), Component.For <ListDepAsConstructor>().Named("InjectAllList"), Component.For <ListDepAsConstructor>().Named("InjectFooOnlyList") .DependsOn(ServiceOverride.ForKey("services").Eq(new[] { "foo" })), Component.For <ListDepAsConstructor>().Named("InjectFooAndBarOnlyList") .DependsOn(ServiceOverride.ForKey("services").Eq(new[] { "foo", "bar" }))); }
public void Install(IWindsorContainer container) { container.AddFacility <EventPublisherFacility>(); container.AddFacility <StartableFacility>(); container.AddFacility <DockingFacility>(); container.AddFacility <MenuFacility>(); container.AddComponent("applicationShell", typeof(IApplicationShell), typeof(ApplicationShell)); container.AddComponent("presenter.factory", typeof(IPresenterFactory), typeof(PresenterFactory)); container.Register( Component.For <IImageSource>().ImplementedBy <ResourceManagerImageSource>().Named("imageSource.res")); container.Register( Component.For <IImageFactory>() .ImplementedBy <ImageFactory>() .ServiceOverrides( ServiceOverride.ForKey("sources").Eq <IImageSource>("imageSource.res"))); // todo: refactor to register all views and presenters declaratively. container.Register( Component.For <IOutputView>().ImplementedBy <OutputView>(), Component.For <IOutputPresenter>().ImplementedBy <OutputPresenter>(), Component.For <IProjectExplorerView>().ImplementedBy <ProjectExplorerView>(), Component.For <IProjectExplorerPresenter>().ImplementedBy <ProjectExplorerPresenter>(), Component.For <IPropertyGridView>().ImplementedBy <PropertyGridView>(), Component.For <IPropertyGridPresenter>().ImplementedBy <PropertyGridPresenter>(), Component.For <IToolBoxView>().ImplementedBy <ToolBoxView>(), Component.For <IToolBoxPresenter>().ImplementedBy <ToolBoxPresenter>()); container.Register( Component .For <IMenuPresenter>() .ImplementedBy <MenuStripPresenter>() .Parameters( Parameter .ForKey("menu") .Eq("${" + MainMenuToolStripKey + "}"))); container.Register(AllTypes.Of <AbstractCommand>().FromAssembly(typeof(AbstractCommand).Assembly)); container.Register( Component.For <DockedWindowsMenuModel>()); }
public void Typed_arguments_work_for_open_generic_ServiceOverrides_closed_service_preferred_over_open_service() { Kernel.Register( Component.For(typeof(IGeneric <>)).ImplementedBy(typeof(GenericImpl1 <>)).Named("default"), Component.For(typeof(IGeneric <>)).ImplementedBy(typeof(GenericImpl2 <>)).Named("non-default-open") .DependsOn(Property.ForKey("value").Eq(1)), Component.For(typeof(IGeneric <>)).ImplementedBy(typeof(GenericImpl2 <>)).Named("non-default-int") .DependsOn(Property.ForKey("value").Eq(2)), Component.For(typeof(UsesIGeneric <>)) .ServiceOverrides(ServiceOverride.ForKey(typeof(IGeneric <>)).Eq("non-default-open"), ServiceOverride.ForKey(typeof(IGeneric <int>)).Eq("non-default-int")) ); var withString = Kernel.Resolve <UsesIGeneric <string> >(); var withInt = Kernel.Resolve <UsesIGeneric <int> >(); Assert.IsInstanceOf <GenericImpl2 <string> >(withString.Dependency); Assert.AreEqual(1, (withString.Dependency as GenericImpl2 <string>).Value); Assert.IsInstanceOf <GenericImpl2 <int> >(withInt.Dependency); Assert.AreEqual(2, (withInt.Dependency as GenericImpl2 <int>).Value); }
/// <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(IWindsorContainer container, IConfigurationStore store) { if (container == null) { throw new ArgumentNullException(nameof(container)); } GatewayServiceMapper.Register(); const string GatewaysContextLocatorName = "GatewaysContextLocator"; const string ContextLocatorFieldName = "contextLocator"; container.Register( Component.For <Func <GatewaysContext> >().Instance(() => new GatewaysContext()) .Named(GatewaysContextLocatorName)); container.Register( Component.For <IGatewaysDataService>().ImplementedBy <GatewaysDataService>() .DependsOn(ServiceOverride.ForKey(ContextLocatorFieldName).Eq(GatewaysContextLocatorName))); }
public static void RegisterMethodLogInterceptor(this IWindsorContainer container, string name, ILogListener logListener) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException(); } if (logListener == null) { throw new ArgumentException(); } container.Register( Component.For <MethodLogInterceptor>().Named(name).DependsOn(ServiceOverride.ForKey <ILogger>().Eq($"{name}Logger")).DependsOn(ServiceOverride.ForKey <IMethodLogMessageFactory>().Eq($"{name}ElapsedMethodLogMessageFactory")), Component.For <ILogger>().UsingFactoryMethod(kernel => CreateLogger(kernel, $"{name}LogListener")).Named($"{name}Logger"), Component.For <ILogListener>().Instance(logListener).Named($"{name}LogListener").LifestyleSingleton(), Component.For <IMethodLogMessageFactory>().ImplementedBy <ElapsedMethodLogMessageFactory>().Named($"{name}ElapsedMethodLogMessageFactory").DependsOn(ServiceOverride.ForKey <IMethodLogMessageFactory>().Eq($"{name}MethodLogMessageFactory")), Component.For <IMethodLogMessageFactory>().ImplementedBy <MethodLogMessageFactory>().Named($"{name}MethodLogMessageFactory").DependsOn(ServiceOverride.ForKey <ILogValueMapper>().Eq($"{name}LogValueMapper"), ServiceOverride.ForKey <ILogMessageSettings>().Eq($"{name}LogMessageSettings")), Component.For <ILogMessageSettings>().ImplementedBy <LogMessageSettings>().Named($"{name}LogMessageSettings"), Component.For <ILogValueMapper>().ImplementedBy <LogValueMapper>().Named($"{name}LogValueMapper").DependsOn(ServiceOverride.ForKey <ILogValueMapperConfigurator>().Eq($"{name}LogValueMapperConfigurator")), Component.For <ILogValueMapperConfigurator>().ImplementedBy <DefaultLogValueMapperConfigurator>().Named($"{name}LogValueMapperConfigurator")); }
public void MultiCore() { const string core0url = "http://localhost:8983/solr/core0"; const string core1url = "http://localhost:8983/solr/core1"; var solrFacility = new SolrNetFacility(core0url); var container = new WindsorContainer(); container.AddFacility("solr", solrFacility); // override core1 components const string core1Connection = "core1.connection"; container.Register(Component.For <ISolrConnection>().ImplementedBy <SolrConnection>().Named(core1Connection) .Parameters(Parameter.ForKey("serverURL").Eq(core1url))); container.Register(Component.For(typeof(ISolrBasicOperations <Core1Entity>), typeof(ISolrBasicReadOnlyOperations <Core1Entity>)) .ImplementedBy <SolrBasicServer <Core1Entity> >() .ServiceOverrides(ServiceOverride.ForKey("connection").Eq(core1Connection))); container.Register(Component.For <ISolrQueryExecuter <Core1Entity> >().ImplementedBy <SolrQueryExecuter <Core1Entity> >() .ServiceOverrides(ServiceOverride.ForKey("connection").Eq(core1Connection))); // assert that everything is correctly wired container.Kernel.DependencyResolving += (client, model, dep) => { if (model.TargetType == typeof(ISolrConnection)) { if (client.Service == typeof(ISolrBasicOperations <Core1Entity>) || client.Service == typeof(ISolrQueryExecuter <Core1Entity>)) { Assert.AreEqual(core1url, ((SolrConnection)dep).ServerURL); } if (client.Service == typeof(ISolrBasicOperations <Document>) || client.Service == typeof(ISolrQueryExecuter <Document>)) { Assert.AreEqual(core0url, ((SolrConnection)dep).ServerURL); } } }; container.Resolve <ISolrOperations <Core1Entity> >(); container.Resolve <ISolrOperations <Document> >(); }
public void AddComponent_GenericListServiceOverrides_WorksFine() { Kernel.Register( Component.For <ICommon>() .Named("common1") .ImplementedBy <CommonImpl1>(), Component.For <ICommon>() .Named("common2") .ImplementedBy <CommonImpl2>(), Component.For <ClassWithListConstructor>() .ServiceOverrides( ServiceOverride.ForKey("services").Eq <ICommon>("common1", "common2") ) ); var common1 = Kernel.Resolve <ICommon>("common1"); var common2 = Kernel.Resolve <ICommon>("common2"); var component = Kernel.Resolve <ClassWithListConstructor>(); Assert.AreEqual(2, component.Services.Count); Assert.AreSame(common1, component.Services[0]); Assert.AreSame(common2, component.Services[1]); }
/// <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(IWindsorContainer container, IConfigurationStore store) { if (container == null) { throw new ArgumentNullException(nameof(container)); } UserServiceMapper.Register(); container.Register( Component.For <IPasswordEncoder>().ImplementedBy <PasswordEncoder>()); const string UsersContextLocatorName = "UsersContextLocator"; const string ContextLocatorFieldName = "contextLocator"; container.Register( Component.For <Func <UsersContext> >().Instance(() => new UsersContext()) .Named(UsersContextLocatorName)); container.Register( Component.For <IUsersDataService>().ImplementedBy <UsersDataService>() .DependsOn(ServiceOverride.ForKey(ContextLocatorFieldName).Eq(UsersContextLocatorName))); }
public static void RegisterHashCodeMethodLogAsyncInterceptor <TLogListenerFactory>(this IWindsorContainer container, string name, string loggerName) where TLogListenerFactory : ILogListenerFactory, new() { if (string.IsNullOrEmpty(name)) { throw new ArgumentException(); } if (string.IsNullOrEmpty(loggerName)) { throw new ArgumentException(); } container.Register( Component.For <MethodLogAsyncInterceptor>().Named(name).DependsOn(ServiceOverride.ForKey <ILogger>().Eq($"{name}Logger")).DependsOn(ServiceOverride.ForKey <IMethodLogMessageFactory>().Eq($"{name}ElapsedMethodLogMessageFactory")), Component.For <ILogger>().UsingFactoryMethod(kernel => CreateLogger(kernel, $"{name}LogListener")).Named($"{name}Logger"), Component.For <ILogListenerFactory>().ImplementedBy <TLogListenerFactory>().Named($"{name}LogListenerFactory"), Component.For <ILogListener>().UsingFactoryMethod(kernel => kernel.Resolve <ILogListenerFactory>($"{name}LogListenerFactory").CreateLogListener(loggerName)).Named($"{name}LogListener").LifestyleSingleton(), Component.For <IMethodLogMessageFactory>().ImplementedBy <ElapsedMethodLogMessageFactory>().Named($"{name}ElapsedMethodLogMessageFactory").DependsOn(ServiceOverride.ForKey <IMethodLogMessageFactory>().Eq($"{name}HashCodeMethodLogMessageFactory")), Component.For <IMethodLogMessageFactory>().ImplementedBy <HashCodeMethodLogMessageFactory>().Named($"{name}HashCodeMethodLogMessageFactory").DependsOn(ServiceOverride.ForKey <IMethodLogMessageFactory>().Eq($"{name}MethodLogMessageFactory")), Component.For <IMethodLogMessageFactory>().ImplementedBy <MethodLogMessageFactory>().Named($"{name}MethodLogMessageFactory").DependsOn(ServiceOverride.ForKey <ILogValueMapper>().Eq($"{name}LogValueMapper"), ServiceOverride.ForKey <ILogMessageSettings>().Eq($"{name}LogMessageSettings")), Component.For <ILogMessageSettings>().ImplementedBy <HashCodeLogMessageSettings>().Named($"{name}LogMessageSettings"), Component.For <ILogValueMapper>().ImplementedBy <LogValueMapper>().Named($"{name}LogValueMapper").DependsOn(ServiceOverride.ForKey <ILogValueMapperConfigurator>().Eq($"{name}LogValueMapperConfigurator")), Component.For <ILogValueMapperConfigurator>().ImplementedBy <DefaultLogValueMapperConfigurator>().Named($"{name}LogValueMapperConfigurator")); }
public void Install(IWindsorContainer container, IConfigurationStore store) { const bool enableLocalization = true; var absoluteFileName = HostingEnvironment.MapPath("~/Sitemap/Mvc.sitemap"); var absoluteCacheExpiration = TimeSpan.FromMinutes(5); const bool visibilityAffectsDescendants = true; const bool useTitleIfDescriptionNotProvided = true; const bool securityTrimmingEnabled = false; string[] includeAssembliesForScan = { "MusicStore.WebUI" }; container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true)); var currentAssembly = GetType().Assembly; var siteMapProviderAssembly = typeof(SiteMaps).Assembly; var dynamicNodeAssembly = typeof(GenreDynamicNodeProvider).Assembly; var allAssemblies = new[] { currentAssembly, siteMapProviderAssembly, dynamicNodeAssembly }; var excludeTypes = new[] { typeof(SiteMapNodeUrlResolver) }; var multipleImplementationTypes = new[] { typeof(ISiteMapNodeUrlResolver), typeof(ISiteMapNodeVisibilityProvider), typeof(IDynamicNodeProvider) }; CommonConventions.RegisterDefaultConventions( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), new[] { siteMapProviderAssembly }, allAssemblies, excludeTypes, string.Empty); CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), multipleImplementationTypes, allAssemblies, new Type[0], string.Empty); CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(implementationType).ImplementedBy(implementationType).LifestyleTransient()), new[] { typeof(IController) }, new[] { siteMapProviderAssembly }, new Type[0], string.Empty); container.Register( Component.For <ISiteMapNodeVisibilityProviderStrategy>() .ImplementedBy <SiteMapNodeVisibilityProviderStrategy>() .DependsOn(Dependency.OnValue("defaultProviderName", string.Empty))); container.Register(Component.For <ControllerBuilder>().Instance(ControllerBuilder.Current)); container.Register( Component.For <IControllerTypeResolverFactory>() .ImplementedBy <ControllerTypeResolverFactory>() .DependsOn(Dependency.OnValue("areaNamespacesToIgnore", new string[0]))); container.Register( Component.For <IAclModule>() .ImplementedBy <CompositeAclModule>() .DependsOn(Dependency.OnComponentCollection <IEnumerable <IAclModule> >(typeof(AuthorizeAttributeAclModule), typeof(XmlRolesAclModule)))); container.Register(Component.For <IAclModule>().ImplementedBy <AuthorizeAttributeAclModule>()); container.Register(Component.For <IAclModule>().ImplementedBy <XmlRolesAclModule>()); container.Register(Component.For <ObjectCache>().Instance(MemoryCache.Default)); container.Register(Component.For(typeof(ICacheProvider <>)).ImplementedBy(typeof(RuntimeCacheProvider <>))); container.Register( Component.For <ICacheDependency>() .ImplementedBy <RuntimeFileCacheDependency>() .Named("cacheDependency1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); container.Register( Component.For <ICacheDetails>() .ImplementedBy <CacheDetails>() .Named("cacheDetails1") .DependsOn(Dependency.OnValue("absoluteCacheExpiration", absoluteCacheExpiration)) .DependsOn(Dependency.OnValue("slidingCacheExpiration", TimeSpan.MinValue)) .DependsOn(ServiceOverride.ForKey <ICacheDependency>().Eq("cacheDependency1"))); container.Register(Component.For <ISiteMapNodeVisitor>().ImplementedBy <UrlResolvingSiteMapNodeVisitor>()); container.Register( Component.For <IXmlSource>() .ImplementedBy <FileXmlSource>() .Named("xmlSource1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); container.Register( Component.For <IReservedAttributeNameProvider>() .ImplementedBy <ReservedAttributeNameProvider>() .DependsOn(Dependency.OnValue("attributesToIgnore", new string[0]))); container.Register( Component.For <ISiteMapNodeProvider>() .ImplementedBy <CompositeSiteMapNodeProvider>() .Named("siteMapNodeProvider1") .DependsOn(Dependency.OnComponentCollection <ISiteMapNodeProvider[]>("xmlSiteMapNodeProvider1", "reflectionSiteMapNodeProvider1"))); container.Register( Component.For <ISiteMapNodeProvider>() .ImplementedBy <XmlSiteMapNodeProvider>() .Named("xmlSiteMapNodeProvider1") .DependsOn(Dependency.OnValue("includeRootNode", true)) .DependsOn(Dependency.OnValue("useNestedDynamicNodeRecursion", false)) .DependsOn(ServiceOverride.ForKey <IXmlSource>().Eq("xmlSource1"))); container.Register( Component.For <ISiteMapNodeProvider>() .ImplementedBy <ReflectionSiteMapNodeProvider>() .Named("reflectionSiteMapNodeProvider1") .DependsOn(Dependency.OnValue("includeAssemblies", includeAssembliesForScan)) .DependsOn(Dependency.OnValue("excludeAssemblies", new string[0]))); container.Register( Component.For <ISiteMapBuilder>() .ImplementedBy <SiteMapBuilder>() .Named("builder1") .DependsOn(ServiceOverride.ForKey <ISiteMapNodeProvider>().Eq("siteMapNodeProvider1"))); container.Register( Component.For <ISiteMapBuilderSet>() .ImplementedBy <SiteMapBuilderSet>() .Named("siteMapBuilderSet1") .DependsOn(Dependency.OnValue("instanceName", "default")) .DependsOn(Dependency.OnValue("securityTrimmingEnabled", securityTrimmingEnabled)) .DependsOn(Dependency.OnValue("enableLocalization", enableLocalization)) .DependsOn(Dependency.OnValue("visibilityAffectsDescendants", visibilityAffectsDescendants)) .DependsOn(Dependency.OnValue("useTitleIfDescriptionNotProvided", useTitleIfDescriptionNotProvided)) .DependsOn(ServiceOverride.ForKey <ISiteMapBuilder>().Eq("builder1")) .DependsOn(ServiceOverride.ForKey <ICacheDetails>().Eq("cacheDetails1"))); container.Register( Component.For <ISiteMapBuilderSetStrategy>() .ImplementedBy <SiteMapBuilderSetStrategy>() .DependsOn(Dependency.OnComponentCollection <ISiteMapBuilderSet[]>("siteMapBuilderSet1"))); }
public void Install(IWindsorContainer container, IConfigurationStore store) { bool enableLocalization = true; string absoluteFileName = HostingEnvironment.MapPath("~/Mvc.sitemap"); TimeSpan absoluteCacheExpiration = TimeSpan.FromMinutes(5); bool visibilityAffectsDescendants = true; bool useTitleIfDescriptionNotProvided = true; #if Demo // Settings for MvcMusicStore demo: don't copy into your project bool securityTrimmingEnabled = true; string[] includeAssembliesForScan = new string[] { "Mvc Music Store" }; #else bool securityTrimmingEnabled = false; string[] includeAssembliesForScan = new string[] { "$AssemblyName$" }; #endif // Configure Windsor to resolve arrays in constructors container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true)); var currentAssembly = this.GetType().Assembly; var siteMapProviderAssembly = typeof(SiteMaps).Assembly; var allAssemblies = new Assembly[] { currentAssembly, siteMapProviderAssembly }; var excludeTypes = new Type[] { // Use this array to add types you wish to explicitly exclude from convention-based // auto-registration. By default all types that either match I[TypeName] = [TypeName] or // I[TypeName] = [TypeName]Adapter will be automatically wired up as long as they don't // have the [ExcludeFromAutoRegistrationAttribute]. // // If you want to override a type that follows the convention, you should add the name // of either the implementation name or the interface that it inherits to this list and // add your manual registration code below. This will prevent duplicate registrations // of the types from occurring. // Example: // typeof(SiteMap), // typeof(SiteMapNodeVisibilityProviderStrategy) typeof(SiteMapNodeUrlResolver) }; var multipleImplementationTypes = new Type[] { typeof(ISiteMapNodeUrlResolver), typeof(ISiteMapNodeVisibilityProvider), typeof(IDynamicNodeProvider) }; // Matching type name (I[TypeName] = [TypeName]) or matching type name + suffix Adapter (I[TypeName] = [TypeName]Adapter) // and not decorated with the [ExcludeFromAutoRegistrationAttribute]. CommonConventions.RegisterDefaultConventions( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), new Assembly[] { siteMapProviderAssembly }, allAssemblies, excludeTypes, string.Empty); // Multiple implementations of strategy based extension points (and not decorated with [ExcludeFromAutoRegistrationAttribute]). CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), multipleImplementationTypes, allAssemblies, new Type[0], string.Empty); // Registration of internal controllers CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(implementationType).ImplementedBy(implementationType).LifestyleTransient()), new Type[] { typeof(IController) }, new Assembly[] { siteMapProviderAssembly }, new Type[0], string.Empty); // Visibility Providers container.Register(Component.For <ISiteMapNodeVisibilityProviderStrategy>().ImplementedBy <SiteMapNodeVisibilityProviderStrategy>() .DependsOn(Dependency.OnValue("defaultProviderName", string.Empty))); // Pass in the global controllerBuilder reference container.Register(Component.For <ControllerBuilder>().Instance(ControllerBuilder.Current)); container.Register(Component.For <IControllerTypeResolverFactory>().ImplementedBy <ControllerTypeResolverFactory>() .DependsOn(Dependency.OnValue("areaNamespacesToIgnore", new string[0]))); // Configure Security // First registration wins - we must do the outer one first container.Register(Component.For <IAclModule>().ImplementedBy <CompositeAclModule>() .DependsOn(Dependency.OnComponentCollection <IEnumerable <IAclModule> >(typeof(AuthorizeAttributeAclModule), typeof(XmlRolesAclModule)))); container.Register(Component.For <IAclModule>().ImplementedBy <AuthorizeAttributeAclModule>()); container.Register(Component.For <IAclModule>().ImplementedBy <XmlRolesAclModule>()); // Setup cache #if NET35 container.Register(Component.For(typeof(ICacheProvider <>)).ImplementedBy(typeof(AspNetCacheProvider <>))); container.Register(Component.For <ICacheDependency>().ImplementedBy <AspNetFileCacheDependency>().Named("cacheDependency1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); #else container.Register(Component.For <System.Runtime.Caching.ObjectCache>().Instance(System.Runtime.Caching.MemoryCache.Default)); container.Register(Component.For(typeof(ICacheProvider <>)).ImplementedBy(typeof(RuntimeCacheProvider <>))); container.Register(Component.For <ICacheDependency>().ImplementedBy <RuntimeFileCacheDependency>().Named("cacheDependency1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); #endif container.Register(Component.For <ICacheDetails>().ImplementedBy <CacheDetails>().Named("cacheDetails1") .DependsOn(Dependency.OnValue("absoluteCacheExpiration", absoluteCacheExpiration)) .DependsOn(Dependency.OnValue("slidingCacheExpiration", TimeSpan.MinValue)) .DependsOn(ServiceOverride.ForKey <ICacheDependency>().Eq("cacheDependency1")) ); // Configure the visitors container.Register(Component.For <ISiteMapNodeVisitor>().ImplementedBy <UrlResolvingSiteMapNodeVisitor>()); // Prepare for the sitemap node providers container.Register(Component.For <IXmlSource>().ImplementedBy <FileXmlSource>().Named("xmlSource1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); container.Register(Component.For <IReservedAttributeNameProvider>().ImplementedBy <ReservedAttributeNameProvider>() .DependsOn(Dependency.OnValue("attributesToIgnore", new string[0]))); // Register the sitemap node providers container.Register(Component.For <ISiteMapNodeProvider>().ImplementedBy <CompositeSiteMapNodeProvider>().Named("siteMapNodeProvider1") .DependsOn(Dependency.OnComponentCollection <ISiteMapNodeProvider[]>("xmlSiteMapNodeProvider1", "reflectionSiteMapNodeProvider1"))); container.Register(Component.For <ISiteMapNodeProvider>().ImplementedBy <XmlSiteMapNodeProvider>().Named("xmlSiteMapNodeProvider1") .DependsOn(Dependency.OnValue("includeRootNode", true)) .DependsOn(Dependency.OnValue("useNestedDynamicNodeRecursion", false)) .DependsOn(ServiceOverride.ForKey <IXmlSource>().Eq("xmlSource1")) ); container.Register(Component.For <ISiteMapNodeProvider>().ImplementedBy <ReflectionSiteMapNodeProvider>().Named("reflectionSiteMapNodeProvider1") .DependsOn(Dependency.OnValue("includeAssemblies", includeAssembliesForScan)) .DependsOn(Dependency.OnValue("excludeAssemblies", new string[0])) ); // Register the sitemap builders container.Register(Component.For <ISiteMapBuilder>().ImplementedBy <SiteMapBuilder>().Named("builder1") .DependsOn(ServiceOverride.ForKey <ISiteMapNodeProvider>().Eq("siteMapNodeProvider1")) ); // Configure the builder sets container.Register(Component.For <ISiteMapBuilderSet>().ImplementedBy <SiteMapBuilderSet>().Named("siteMapBuilderSet1") .DependsOn(Dependency.OnValue("instanceName", "default")) .DependsOn(Dependency.OnValue("securityTrimmingEnabled", securityTrimmingEnabled)) .DependsOn(Dependency.OnValue("enableLocalization", enableLocalization)) .DependsOn(Dependency.OnValue("visibilityAffectsDescendants", visibilityAffectsDescendants)) .DependsOn(Dependency.OnValue("useTitleIfDescriptionNotProvided", useTitleIfDescriptionNotProvided)) .DependsOn(ServiceOverride.ForKey <ISiteMapBuilder>().Eq("builder1")) .DependsOn(ServiceOverride.ForKey <ICacheDetails>().Eq("cacheDetails1")) ); container.Register(Component.For <ISiteMapBuilderSetStrategy>().ImplementedBy <SiteMapBuilderSetStrategy>() .DependsOn(Dependency.OnComponentCollection <ISiteMapBuilderSet[]>("siteMapBuilderSet1"))); }
public void Install(IWindsorContainer container, IConfigurationStore store) { bool securityTrimmingEnabled = false; bool enableLocalization = true; string absoluteFileName = HostingEnvironment.MapPath("~/Mvc.sitemap"); TimeSpan absoluteCacheExpiration = TimeSpan.FromMinutes(5); string[] includeAssembliesForScan = new string[] { "$AssemblyName$" }; // Configure Windsor to resolve arrays in constructors container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true)); var currentAssembly = this.GetType().Assembly; var siteMapProviderAssembly = typeof(SiteMaps).Assembly; var allAssemblies = new Assembly[] { currentAssembly, siteMapProviderAssembly }; var excludeTypes = new Type[] { typeof(SiteMapNodeVisibilityProviderStrategy), typeof(SiteMapXmlReservedAttributeNameProvider), typeof(SiteMapBuilderSetStrategy), typeof(ControllerTypeResolverFactory), typeof(SiteMapNodeUrlResolver) }; var multipleImplementationTypes = new Type[] { typeof(ISiteMapNodeUrlResolver), typeof(ISiteMapNodeVisibilityProvider), typeof(IDynamicNodeProvider) }; // Single implementations of interface with matching name (minus the "I"). CommonConventions.RegisterDefaultConventions( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), new Assembly[] { siteMapProviderAssembly }, allAssemblies, excludeTypes, string.Empty); // Multiple implementations of strategy based extension points CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(interfaceType).ImplementedBy(implementationType).LifestyleSingleton()), multipleImplementationTypes, allAssemblies, new Type[0], "^Composite"); // Registration of internal controllers CommonConventions.RegisterAllImplementationsOfInterface( (interfaceType, implementationType) => container.Register(Component.For(implementationType).ImplementedBy(implementationType).LifestyleTransient()), new Type[] { typeof(IController) }, new Assembly[] { siteMapProviderAssembly }, new Type[0], string.Empty); // Visibility Providers container.Register(Component.For <ISiteMapNodeVisibilityProviderStrategy>().ImplementedBy <SiteMapNodeVisibilityProviderStrategy>() .DependsOn(Dependency.OnValue("defaultProviderName", string.Empty))); // Pass in the global controllerBuilder reference container.Register(Component.For <ControllerBuilder>().Instance(ControllerBuilder.Current)); container.Register(Component.For <IControllerBuilder>().ImplementedBy <ControllerBuilderAdaptor>()); container.Register(Component.For <IBuildManager>().ImplementedBy <BuildManagerAdaptor>()); container.Register(Component.For <IControllerTypeResolverFactory>().ImplementedBy <ControllerTypeResolverFactory>() .DependsOn(Dependency.OnValue("areaNamespacesToIgnore", new string[0]))); // Configure Security // First registration wins - we must do the outer one first container.Register(Component.For <IAclModule>().ImplementedBy <CompositeAclModule>() .DependsOn(Dependency.OnComponentCollection <IEnumerable <IAclModule> >(typeof(AuthorizeAttributeAclModule), typeof(XmlRolesAclModule)))); container.Register(Component.For <IAclModule>().ImplementedBy <AuthorizeAttributeAclModule>()); container.Register(Component.For <IAclModule>().ImplementedBy <XmlRolesAclModule>()); // Setup cache #if NET35 container.Register(Component.For(typeof(ICacheProvider <>)).ImplementedBy(typeof(AspNetCacheProvider <>))); container.Register(Component.For <ICacheDependency>().ImplementedBy <AspNetFileCacheDependency>().Named("cacheDependency1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); #else container.Register(Component.For <System.Runtime.Caching.ObjectCache>().Instance(System.Runtime.Caching.MemoryCache.Default)); container.Register(Component.For(typeof(ICacheProvider <>)).ImplementedBy(typeof(RuntimeCacheProvider <>))); container.Register(Component.For <ICacheDependency>().ImplementedBy <RuntimeFileCacheDependency>().Named("cacheDependency1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); #endif container.Register(Component.For <ICacheDetails>().ImplementedBy <CacheDetails>().Named("cacheDetails1") .DependsOn(Dependency.OnValue("absoluteCacheExpiration", absoluteCacheExpiration)) .DependsOn(Dependency.OnValue("slidingCacheExpiration", TimeSpan.MinValue)) .DependsOn(ServiceOverride.ForKey <ICacheDependency>().Eq("cacheDependency1")) ); // Configure the visitors container.Register(Component.For <ISiteMapNodeVisitor>().ImplementedBy <UrlResolvingSiteMapNodeVisitor>()); // Register the sitemap builder container.Register(Component.For <IXmlSource>().ImplementedBy <FileXmlSource>().Named("xmlSource1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); container.Register(Component.For <ISiteMapXmlReservedAttributeNameProvider>().ImplementedBy <SiteMapXmlReservedAttributeNameProvider>() .DependsOn(Dependency.OnValue("attributesToIgnore", new string[0]))); container.Register(Component.For <ISiteMapBuilder>().ImplementedBy <CompositeSiteMapBuilder>().Named("builder1") .DependsOn(Dependency.OnComponentCollection <ISiteMapBuilder[]>("xmlSiteMapBuilder1", "reflectionSiteMapBuilder1", "visitingSiteMapBuilder1"))); container.Register(Component.For <ISiteMapBuilder>().ImplementedBy <XmlSiteMapBuilder>().Named("xmlSiteMapBuilder1") .DependsOn(Dependency.OnValue <ISiteMapXmlReservedAttributeNameProvider>(container.Resolve <ISiteMapXmlReservedAttributeNameProvider>())) .DependsOn(ServiceOverride.ForKey <IXmlSource>().Eq("xmlSource1")) ); container.Register(Component.For <ISiteMapBuilder>().ImplementedBy <ReflectionSiteMapBuilder>().Named("reflectionSiteMapBuilder1") .DependsOn(Dependency.OnValue("includeAssemblies", includeAssembliesForScan)) .DependsOn(Dependency.OnValue("excludeAssemblies", new string[0])) ); container.Register(Component.For <ISiteMapBuilder>().ImplementedBy <VisitingSiteMapBuilder>().Named("visitingSiteMapBuilder1")); // Configure the builder sets container.Register(Component.For <ISiteMapBuilderSet>().ImplementedBy <SiteMapBuilderSet>().Named("siteMapBuilderSet1") .DependsOn(Dependency.OnValue("instanceName", "default")) .DependsOn(Dependency.OnValue("securityTrimmingEnabled", securityTrimmingEnabled)) .DependsOn(Dependency.OnValue("enableLocalization", enableLocalization)) .DependsOn(ServiceOverride.ForKey <ISiteMapBuilder>().Eq("builder1")) .DependsOn(ServiceOverride.ForKey <ICacheDetails>().Eq("cacheDetails1")) ); container.Register(Component.For <ISiteMapBuilderSetStrategy>().ImplementedBy <SiteMapBuilderSetStrategy>() .DependsOn(Dependency.OnComponentCollection <ISiteMapBuilderSet[]>("siteMapBuilderSet1"))); }