Exemplo n.º 1
0
        public void Start(Boolean autoStartJobs = true)
        {
            _container = new WindsorContainer();
            if (autoStartJobs)
            {
                _container.AddFacility <StartableFacility>();
            }

            _container.AddFacility <LoggingFacility>(f =>
                                                     f.LogUsing(LoggerImplementation.ExtendedLog4net)
                                                     .WithConfig("log4net.config"));

            ConfigurationServiceSettingsConfiguration config = new ConfigurationServiceSettingsConfiguration();

            _container.Register(
                Component.For <Func <IMongoDatabase, ICommitReader> >()
                .Instance(d => new PlainCommitMongoReader(d)),
                Component.For <Func <String, Int64, ICommitWriter> >()
                .Instance((directory, fileSize) => new PlainTextFileCommitWriter(directory, fileSize)),
                Component
                .For <Configuration>()
                .Instance(config),
                Component
                .For <BackupJob>(),
                Component
                .For <RestoreJob>()
                );
        }
Exemplo n.º 2
0
        private static void ResolveByNamWhenYouDontHaveAccessToTheContainer()
        {
            // add factory by type feature
            _container.AddFacility <TypedFactoryFacility>();
            _container.Register(Component.For <NamedTypeFactorySelector>());

            _container.Register(Component.For <IFactory>().
                                AsFactory(s => s.SelectedWith <NamedTypeFactorySelector>()));

            _container.Register(Component.For <IEngineA>().ImplementedBy <EngineA1>().LifestyleTransient().Named("action1"));
            _container.Register(Component.For <IEngineA>().ImplementedBy <EngineA2>().LifestyleTransient().Named("action2"));

            var      factory  = _container.Resolve <IFactory>();
            IEngineA engineA1 = factory.Create("action1");
            IEngineA engineA2 = factory.Create("action2");


            _container.Register(Component.For <IService>().ImplementedBy <ServiceThatUsFactory>().LifestyleTransient());
            _container.Register(Component.For <IStuff1>().ImplementedBy <Stuff1>().LifestyleTransient());
            _container.Register(Component.For <IStuff2>().ImplementedBy <Stuff2>().LifestyleTransient());
            _container.Register(Component.For <IStuff3>().ImplementedBy <Stuff3>().LifestyleTransient());
            _container.Register(Component.For <IRepository1>().ImplementedBy <Repository1>().LifestyleTransient());
            _container.Register(Component.For <IRepository2>().ImplementedBy <Repository2>().LifestyleTransient());

            IService service = _container.Resolve <IService>();

            while (true)
            {
                Console.WriteLine("insert action:");
                var action = Console.ReadLine();
                service.Execute(action);
            }
        }
Exemplo n.º 3
0
 private static void AddResolversAndFacilities(IWindsorContainer container)
 {
     container.Kernel.Resolver.AddSubResolver(new CachingSessionResolver());
     container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
     container.AddFacility<TypedFactoryFacility>();
     container.AddFacility<StartableFacility>();
 }
Exemplo n.º 4
0
 private static void AddResolversAndFacilities(IWindsorContainer container)
 {
     container.Kernel.Resolver.AddSubResolver(new CachingSessionResolver());
     container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
     container.AddFacility <TypedFactoryFacility>();
     container.AddFacility <StartableFacility>();
 }
Exemplo n.º 5
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<SqlServerPersistenceFacility>();
            container.AddFacility<DomainServicesFacility>();
            container.AddFacility<ApplicationServicesFacility>();

            container.Register(
                Classes.FromThisAssembly()
                    .BasedOn(typeof (IBootstrapper))
                    .WithServiceBase()
                    .LifestyleSingleton());

            // for bootstrappers
            container.Register(
                Component.For<WindsorControllerFactory>().ImplementedBy<WindsorControllerFactory>().LifestyleSingleton(),
                Component.For<WindsorValidatorFactory>().ImplementedBy<WindsorValidatorFactory>().LifestyleSingleton());

            // register all Fluent Validators
            container.Register(
                Classes.FromThisAssembly()
                .BasedOn(typeof(IValidator<>))
                .WithServiceBase()
                .LifestyleTransient());

            // register all controllers
            container.Register(Classes.FromThisAssembly()
                            .BasedOn<IController>()
                            .LifestyleTransient());
        }
Exemplo n.º 6
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.AddFacility <InfrastructureIocFacility>();
     container.AddFacility <EFIocFacility>();
     container.AddFacility <ConfigIocFacility>();
     container.AddFacility <ApplicationIocFacility>();
 }
Exemplo n.º 7
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<LoggingFacility>(
                facility => facility.UseNLog().LogUsing(LoggerImplementation.NLog).WithConfig(NlogConfigPath));

            container.Register(
                Component.For<IInterceptor>().ImplementedBy<ExceptionInterceptor>(),
                Component.For<ICommandFactory>().AsFactory(),
                Component.For<IQueryFactory>().AsFactory(),

                Classes.FromThisAssembly().BasedOn<ICommand>().WithServiceSelf().LifestylePerWebRequest(),
                Classes.FromThisAssembly().BasedOn<IQuery>().WithServiceSelf().LifestylePerWebRequest(),

                Component.For<IPayrollDetailsHelper>()
                    .ImplementedBy<PayrollDetailsHelper>()
                    .DependsOn(Dependency.OnValue("benefitsDeduction", Convert.ToInt32(GetConfigValue("benefitsDeduction"))))
                    .DependsOn(Dependency.OnValue("dependentDeductions", Convert.ToInt32(GetConfigValue("dependentDeductions"))))
                    .DependsOn(Dependency.OnValue("savingsPercentage", Convert.ToInt32(GetConfigValue("SavingsPercentage"))))
                    .LifestylePerWebRequest(),

                Component.For<IDapperHub>()
                    .ImplementedBy<DapperHub>()
                    .DependsOn(Dependency.OnValue("databaseConnection", GetConnectionString()))
                    .LifestylePerWebRequest(),
                
                Classes.FromThisAssembly().BasedOn<ApiController>().LifestyleTransient().Configure(registration => registration.Interceptors<ExceptionInterceptor>()));
        }
 private void InstallFacilities(IWindsorContainer container)
 {
     _logger.Debug("Installing facilities");
     container.AddFacility <TypedFactoryFacility>();
     container.AddFacility <DatabaseConnectionStringProviderFacility>();
     container.AddFacility <ChainOfResponsibilityFacility>();
 }
		private void Start()
		{
			container = new WindsorContainer();
			container.AddFacility<LoggingFacility>(f => f.UseNLog());

			container
				.AddFacility<AutoTxFacility>()
				.Register(
                    Component.For<IConfigurationPersister>().ImplementedBy<FileConfigurationPersister>(),
					Component.For<INHibernateInstaller>().ImplementedBy<NHibInstaller>().LifeStyle.Singleton,
					Component.For<Logger>().LifeStyle.Singleton)
				.AddFacility<NHibernateFacility>();

			using (var scope = new ResolveScope<Logger>(container))
			{
				using (var up = new ResolveScope<Configuration>(container))
				{
					new SchemaUpdate(up.Service).Execute(false, true);
				}

				Console.WriteLine("Current log contents:");
				Console.WriteLine("[utc date] - [text]");
				Console.WriteLine("-------------------");
				scope.Service.ReadLog(Console.WriteLine); // read everything from saved log
				scope.Service.WriteToLog(string.Format("{0} - Started", DateTime.UtcNow)); // write simple line to log
			}
		}
Exemplo n.º 10
0
        public void Start(Boolean autoStartJobs = true)
        {
            _container = new WindsorContainer();
            if (autoStartJobs)
            {
                _container.AddFacility <StartableFacility>();
            }

            _container.AddFacility <LoggingFacility>(f =>
                                                     f.LogUsing(LoggerImplementation.ExtendedLog4net)
                                                     .WithConfig("log4net.config"));

            _logger = _container.Resolve <ILogger>();

            ConfigurationServiceSettingsConfiguration config = new ConfigurationServiceSettingsConfiguration();

            //Register only the configuration and the backup jobs.
            _container.Register(
                Component
                .For <Configuration>()
                .Instance(config),
                Component
                .For <DocumentStoreBackupJob>()
                );
        }
Exemplo n.º 11
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // Facilities
            container.AddFacility <LoggingFacility>(f => f.LogUsing <Log4netFactory>().WithConfig("log4net.xml"));
            container.AddFacility <EventWiringFacility>();
            container.AddFacility <StartableFacility>(f => f.DeferredStart());
            container.AddFacility <TypedFactoryFacility>();

            // Configuration converters
            var conversionManager =
                (IConversionManager)container.Kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);

            conversionManager.Add(new MediaWikiConfigMapEntryConverter());

            container.Install(
                Configuration.FromXmlFile("alert-templates.xml"),
                new Stwalkerster.IrcClient.Installer(),
                new Stwalkerster.Bot.CommandLib.Startup.Installer()
                );

            container.Register(
                // MediaWiki stuff
                Component.For <IMediaWikiApiTypedFactory>().AsFactory(),
                Component.For <IMediaWikiApi>().ImplementedBy <MediaWikiApi>().LifestyleTransient(),
                Component.For <IWebServiceClient>().ImplementedBy <WebServiceClient>(),

                // Services
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Services").WithServiceAllInterfaces(),
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Services.Email").WithServiceAllInterfaces(),
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Services.ExternalProviders").WithServiceAllInterfaces(),
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Services.RecentChanges").WithServiceAllInterfaces(),
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Services.RecentChanges.Irc").WithServiceAllInterfaces(),
                Classes.FromThisAssembly().InNamespace("EyeInTheSky.Commands").LifestyleTransient()
                .Configure(x => x.DependsOn(Dependency.OnComponent("wikimediaClient", "wikimediaClient"))),

                // Main application
                Component.For <IApplication>()
                .ImplementedBy <Launch>()
                .DependsOn(Dependency.OnComponent("wikimediaClient", "wikimediaClient")),

                Component.For <IIrcClient>()
                .ImplementedBy <IrcClient>()
                .IsDefault()
                .DependsOn(Dependency.OnComponent("configuration", "freenodeIrcConfig"))
                .PublishEvent(
                    p => p.ReceivedMessage += null,
                    x => x.To <CommandHandler>(l => l.OnMessageReceived(null, null))),
                Component.For <IIrcClient>()
                .ImplementedBy <IrcClient>()
                .Named("wikimediaClient")
                .DependsOn(Dependency.OnComponent("configuration", "wikimediaIrcConfig"))
                .PublishEvent(
                    p => p.ReceivedMessage += null,
                    x => x.To <IrcRecentChangeHandler>(l => l.OnReceivedMessage(null, null))),

                // Linked to IRC services, so needs special configuration.
                Component.For <NagiosMonitoringService>()
                .DependsOn(Dependency.OnComponent("wikimediaClient", "wikimediaClient"))
                );
        }
Exemplo n.º 12
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <LoggingFacility>(
                facility => facility.UseNLog().LogUsing(LoggerImplementation.NLog).WithConfig(NlogConfigPath));

            container.Register(
                Component.For <IInterceptor>().ImplementedBy <ExceptionInterceptor>(),
                Component.For <ICommandFactory>().AsFactory(),
                Component.For <IQueryFactory>().AsFactory(),

                Classes.FromThisAssembly().BasedOn <ICommand>().WithServiceSelf().LifestylePerWebRequest(),
                Classes.FromThisAssembly().BasedOn <IQuery>().WithServiceSelf().LifestylePerWebRequest(),

                Component.For <IPayrollDetailsHelper>()
                .ImplementedBy <PayrollDetailsHelper>()
                .DependsOn(Dependency.OnValue("benefitsDeduction", Convert.ToInt32(GetConfigValue("benefitsDeduction"))))
                .DependsOn(Dependency.OnValue("dependentDeductions", Convert.ToInt32(GetConfigValue("dependentDeductions"))))
                .DependsOn(Dependency.OnValue("savingsPercentage", Convert.ToInt32(GetConfigValue("SavingsPercentage"))))
                .LifestylePerWebRequest(),

                Component.For <IDapperHub>()
                .ImplementedBy <DapperHub>()
                .DependsOn(Dependency.OnValue("databaseConnection", GetConnectionString()))
                .LifestylePerWebRequest(),

                Classes.FromThisAssembly().BasedOn <ApiController>().LifestyleTransient().Configure(registration => registration.Interceptors <ExceptionInterceptor>()));
        }
Exemplo n.º 13
0
        public static void BuildContainer()
        {
            BuilderSetup.SetDefaultPropertyNamer(new PersistableEntityPropertyNamer(new ReflectionUtil()));
            _container = new WindsorContainer();

            _container = new WindsorContainer();
            _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel));
            
            _container.AddFacility<ConfigurationFacility>();
            var config = _container.Resolve<IEnvironmentConfiguration>();
            var possiblyInjectedProjectFlavour = Process.GetCurrentProcess().GetProjectFlavour() ?? ProjectFlavour.Application;

            EntityFrameworkDataProviderFacility.ConnectionStringProvider =
                () => config.ConnectionString(possiblyInjectedProjectFlavour);

            EntityFrameworkDataProviderFacility.WithDatabaseInitialiser<AlwaysDropAndRecreateDatabaseStrategyInitialiser>();
            
            _container.AddFacility<EntityFrameworkDataProviderFacility>();

            SecurityInstaller.SecurityHelperType = config.SecurityHelperType(possiblyInjectedProjectFlavour);

            _container.Install(FromAssembly.This());
            
            _container.Register(Component.For<IWindsorContainer>().Instance(_container));
        }
        private void Start()
        {
            container = new WindsorContainer();
            container.AddFacility <LoggingFacility>(f => f.UseNLog());

            container
            .AddFacility <AutoTxFacility>()
            .Register(
                Component.For <IConfigurationPersister>().ImplementedBy <FileConfigurationPersister>(),
                Component.For <INHibernateInstaller>().ImplementedBy <NHibInstaller>().LifeStyle.Singleton,
                Component.For <Logger>().LifeStyle.Singleton)
            .AddFacility <NHibernateFacility>();

            using (var scope = new ResolveScope <Logger>(container))
            {
                using (var up = new ResolveScope <Configuration>(container))
                {
                    new SchemaUpdate(up.Service).Execute(false, true);
                }

                Console.WriteLine("Current log contents:");
                Console.WriteLine("[utc date] - [text]");
                Console.WriteLine("-------------------");
                scope.Service.ReadLog(Console.WriteLine);                                  // read everything from saved log
                scope.Service.WriteToLog(string.Format("{0} - Started", DateTime.UtcNow)); // write simple line to log
            }
        }
Exemplo n.º 15
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <LoggingFacility>();

            container.Register(
                Component.For <IEffect <CastSpell> >()
                .ImplementedBy <BoxOutEffect>()
                .Named("boxOut")
                .LifestyleTransient(),
                Component.For <IEffect <CastSpell> >()
                .ImplementedBy <FlashEffect>()
                .Named("flash")
                .LifestyleTransient(),
                Component.For <IEffect <CastSpell> >()
                .ImplementedBy <MultiColorFlash>()
                .Named("multiflash")
                .LifestyleTransient(),
                Component.For <IEffect <CastSpell> >()
                .ImplementedBy <ExplosionEffect>()
                .Named("explosion")
                .LifestyleTransient(),

                Component.For <IEffectFactory>().AsFactory(f =>
                                                           f.SelectedWith(new NamedCustomSelector())),

                Component.For <ILightsConfigurationProvider>()
                .ImplementedBy <FileConfigurationProvider>()
                .DependsOn(
                    Dependency.OnValue <string>("config.json")),

                Component.For <ILightClientProviderFactory>().AsFactory(),
                Component.For <LightClientManager>(),
                Component.For <IMagicLights>().ImplementedBy <MagicLightsApplication>());
        }
        public IWindsorContainer ConfigureFacilities(IWindsorContainer container)
        {
            var facility = new LoggingFacility(LoggerImplementation.Console);
            container.AddFacility<FactorySupportFacility>();
            container.AddFacility("logging", facility);

            return container;
        }
Exemplo n.º 17
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.AddFacility <Comm100IocFacility>();
     container.AddFacility <ApplicationIocFacility>();
     container.AddFacility <EntityFrameworkIocFacility>();
     //container.AddFacility<DapperIocFacility>();
     container.AddFacility <InfrastructureIocFacility>();
 }
Exemplo n.º 18
0
        public static void ExplainFacilitiesToWindsor(IWindsorContainer container)
        {
            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config"));

            container.Register(Component.For<ILazyComponentLoader>()
                                        .ImplementedBy<LazyOfTComponentLoader>());
        }
Exemplo n.º 19
0
        public void Register(IWindsorContainer container)
        {
            container.AddFacility <ViewPresenterReleaseFacility>();
            container.AddFacility <LifeCycleTracerFacility>();

            RegisterNumGen(container);
            RegisterLauncher(container);
        }
Exemplo n.º 20
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <ManagerFacility>();
            container.AddFacility <ServiceFabricFacility>();

            container.Register(
                Component.For <UserRegistryService>().AsStatefulService("UserRegistryServiceType"));
        }
Exemplo n.º 21
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));

            container.AddFacility(new StartableFacility());
            container.AddFacility <LoggingFacility>(f => f.UseNLog().WithConfig(logFileName ?? "nlog.config"));
            container.AddFacility <TypedFactoryFacility>();
        }
Exemplo n.º 22
0
        /// <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)
        {
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <ServiceFabricFacility>();

            container.Register(
                Component.For <TestStateless>().AsStatelessService("TestStatelessType"));
        }
Exemplo n.º 23
0
		public void Init()
		{
			container = new WindsorContainer();

			container.AddFacility("1", new MyInterceptorGreedyFacility());
			container.AddFacility("2", new MyInterceptorGreedyFacility());
			container.AddFacility("3", new MyInterceptorGreedyFacility());
		}
        public void Init()
        {
            _container = new WindsorContainer();

            _container.AddFacility("1", new MyInterceptorGreedyFacility());
            _container.AddFacility("2", new MyInterceptorGreedyFacility());
            _container.AddFacility("3", new MyInterceptorGreedyFacility());
        }
Exemplo n.º 25
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <TypedFactoryFacility>();

            container.AddFacility <LoggingFacility>(
                f => f
                .LogUsing <NLogFactory>()
                .WithConfig("Logger\\nlog.config")
                );

            container.Register(
                Component.For <IWindsorContainer>()
                .Instance(container)
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For <ILogger>()
                .ImplementedBy <Logger>()
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For <AppServerHost>()
                .Instance(this._host)
                .LifestyleSingleton()
                );

            container.Register(
                Component.For <IAppServerContext>()
                .ImplementedBy <AppServerContext>()
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For(typeof(IAppServiceInvoker <>))
                .ImplementedBy(typeof(AppServiceInvoker <>))
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For(typeof(IAppOperationInvoker <, ,>))
                .ImplementedBy(typeof(AppOperationInvoker <, ,>))
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For <IAppServiceInvokerFactory>()
                .AsFactory()
                .LifeStyle.Singleton
                );

            container.Register(
                Component.For <IAppOperationInvokerFactory>()
                .AsFactory()
                .LifeStyle.Singleton
                );
        }
Exemplo n.º 26
0
 private void BootstrapContainer()
 {
     logger.Debug("Installing Winsdor Castle.");
     Container = new WindsorContainer();
     Container.AddFacility<LoggingFacility>(f => f.UseNLog("NLog.config"));
     Container.AddFacility<TypedFactoryFacility>();
     Container.Register(Component.For<IContainerAccessor>().Instance(this));
     Container.Install(FromAssembly.Containing<CollectorApiInstaller>());
 }
Exemplo n.º 27
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<FactorySupportFacility>();

            container.Register(
                AllTypes.FromAssemblyContaining(typeof (CreateCustomerCommandHandler))
                .Where(x => x.GetInterface(typeof (Consumes<>.All).Name) != null));
        }
Exemplo n.º 28
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <ManagerFacility>();
            container.AddFacility <ServiceFabricFacility>(f => f.Configure(c => c.UsingActors()));

            container.Register(
                Component.For <Encounter>().AsActor().LifestyleTransient(),
                Component.For <EncounterLoader>().AsActor().LifestyleTransient());
        }
Exemplo n.º 29
0
 static void ApplicationConfigure()
 {
     container = new WindsorContainer();
     container.AddFacility("monorail", new MonoRailFacility());
     container.AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, "log4net.config"));
     InitializeNHSessionManagement();
     RegisterWebComponents();
     RegisterComponents();
     InitializeServiceLocator();
 }
Exemplo n.º 30
0
        private static void AddResolversAndFacilities(IWindsorContainer container)
        {
            container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <StartableFacility>();

            container.Register(Component.For <IEmployeeFinder>()
                               .ImplementedBy <EmployeeFinder>()
                               .LifestyleSingleton());
        }
Exemplo n.º 31
0
        /// <summary>
        ///     Called when the first resource (such as a page) in an ASP.NET application is requested.
        /// </summary>
        /// <remarks>
        ///     The Application_Start method is called only one time during the life cycle of an application. You can use this
        ///     method to perform startup tasks such as loading data into the cache and initializing static values. You should set
        ///     only static data during application start. Do not set any instance data because it will be available only to the
        ///     first instance of the HttpApplication class that is created.
        /// </remarks>
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            _container = new WindsorContainer();
            _container.Kernel.Resolver.AddSubResolver(new ListResolver(_container.Kernel));
            _container.AddFacility <TypedFactoryFacility>();
            _container.AddFacility <StartableFacility>(factory => factory.DeferredStart());
            _container.Install(FromAssembly.InThisApplication());
        }
Exemplo n.º 32
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // Facilities
            container.AddFacility <LoggingFacility>(f => f.LogUsing <Log4netFactory>().WithConfig("log4net.xml"));
            container.AddFacility <StartableFacility>(f => f.DeferredStart());

            container.Install(new WebInstaller());

            var ircClientMock = new Mock <IIrcClient>();

            ircClientMock.Setup(x => x.ExtBanTypes).Returns("a");
            ircClientMock.Setup(x => x.ExtBanDelimiter).Returns("$");
            ircClientMock.Setup(x => x.Nickname).Returns("EyeInTheSkyBot");
            ircClientMock.Setup(x => x.ClientName).Returns("Freenode");

            var ircChannels = new Dictionary <string, IrcChannel>();
            var chan        = new IrcChannel("##stwalkerster-development");

            ircChannels.Add(chan.Name, chan);
            ircClientMock.Setup(x => x.Channels).Returns(ircChannels);

            IrcUser        user;
            IrcChannelUser ircChannelUser;

            user                = IrcUser.FromPrefix("stwalkerster!test@user/.", ircClientMock.Object);
            user.Account        = "stwalkerster";
            user.SkeletonStatus = IrcUserSkeletonStatus.Full;
            ircChannelUser      = new IrcChannelUser(user, chan.Name);
            chan.Users.Add(user.Nickname, ircChannelUser);


            user                = IrcUser.FromPrefix("chanmember!test@user/.", ircClientMock.Object);
            user.Account        = "chanmember";
            user.SkeletonStatus = IrcUserSkeletonStatus.Full;
            ircChannelUser      = new IrcChannelUser(user, chan.Name);
            chan.Users.Add(user.Nickname, ircChannelUser);

            user                    = IrcUser.FromPrefix("chanop!test@user/.", ircClientMock.Object);
            user.Account            = "chanop";
            user.SkeletonStatus     = IrcUserSkeletonStatus.Full;
            ircChannelUser          = new IrcChannelUser(user, chan.Name);
            ircChannelUser.Operator = true;
            chan.Users.Add(user.Nickname, ircChannelUser);

            container.Register(
                // Main application
                Component.For <IApplication>().ImplementedBy <Launch>(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services").WithServiceAllInterfaces(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services.ExternalProviders").WithServiceAllInterfaces(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services.Email").WithServiceAllInterfaces(),
                Component.For <IIrcClient>().Instance(ircClientMock.Object)
                );

            container.Install(Configuration.FromXmlFile("alert-templates.xml"));
        }
 internal void AddFacilities(IWindsorContainer container)
 {
     if (!container.Kernel.GetFacilities().Any(f => f is StartableFacility))
     {
         container.AddFacility <StartableFacility>();
     }
     if (!container.Kernel.GetFacilities().Any(f => f is TypedFactoryFacility))
     {
         container.AddFacility <TypedFactoryFacility>();
     }
 }
Exemplo n.º 34
0
 private void SetupWindsor()
 {
     container = new WindsorContainer(new XmlInterpreter());
     var configBuilder = new NHConfigBuilder(Server.MapPath("/"));
     container.AddFacility("nhibernate", new NHibernateFacility(configBuilder));
     container.AddFacility<TransactionFacility>();
     container.AddComponent<TransactionalService>();
     container.AddComponent<HomeController>("home");
     new SchemaExport(configBuilder.GetConfiguration(null)).Execute(false, true, false);
     ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
 }
Exemplo n.º 35
0
        /// <summary>
        /// The register components.
        /// </summary>
        /// <param name="container">
        /// The container.
        /// </param>
        /// <param name="console">
        /// The console.
        /// </param>
        /// <param name="wcf">
        /// The wcf.
        /// </param>
        /// <param name="web">
        /// The web.
        /// </param>
        public static void RegisterComponents(this IWindsorContainer container, bool console = false, bool wcf = false, bool web = false)
        {
            if (wcf)
            {
                container.AddFacility <WcfFacility>();
                container.Register(Component.For <AuthenticationModel>().ImplementedBy(typeof(AuthenticationModel)).LifeStyle.PerWcfOperation());
            }

            container.Register(Component.For <Configuration>().LifeStyle.Singleton.Activator <NHibernateConfigurationActivator>());
            container.Register(Component.For <ISessionFactory>().LifeStyle.Singleton.Activator <Esynctraining.Persistence.NHibernateSessionFactoryActivator>());

            if (console)
            {
                container.Register(Component.For <ISessionSource>().ImplementedBy <NHibernateSessionSource>().LifeStyle.Transient);
            }
            else if (wcf)
            {
                container.Register(Component.For <ISessionSource>().ImplementedBy <NHibernateSessionSource>().LifeStyle.PerWcfOperationIncludingWebOrb());
            }
            else if (web)
            {
                container.Register(Component.For <ISessionSource>().ImplementedBy <NHibernateSessionWebSource>().LifeStyle.PerWebRequest);
            }

            container.Register(Component.For(typeof(IRepository <,>)).ImplementedBy(typeof(Repository <,>)).LifeStyle.Transient);

            if (!console)
            {
                container.Register(Component.For <ApplicationSettingsProvider>().ImplementedBy <ApplicationSettingsProvider>().DynamicParameters((k, d) => d.Add("collection", WebConfigurationManager.AppSettings)).DynamicParameters((k, d) => d.Add("globalizationSection", ConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection)).LifeStyle.Singleton);
            }
            else
            {
                // ReSharper disable RedundantCast (The cast is actually needed here for castle windsor to know the type of null)
                container.Register(Component.For <ApplicationSettingsProvider>().ImplementedBy <ApplicationSettingsProvider>().DynamicParameters((k, d) => d.Add("collection", ConfigurationManager.AppSettings)).DynamicParameters((k, d) => d.Add("globalizationSection", (GlobalizationSection)null)).LifeStyle.Singleton);
                // ReSharper restore RedundantCast
            }

            container.Register(Component.For <HttpServerUtilityBase>().ImplementedBy <HttpServerUtilityWrapper>().DynamicParameters((k, d) => d.Insert("httpServerUtility", HttpContext.Current.Server)).LifeStyle.Transient);

            container.Register(Component.For <ITemplateProvider>().ImplementedBy <TemplateProvider>().LifeStyle.Transient);
            container.Register(Component.For <IAttachmentsProvider>().ImplementedBy <AttachmentsProvider>().LifeStyle.Transient);
            container.Register(Component.For <FullTextModel>().LifeStyle.Singleton);
            container.Register(Component.For <Pdf2SwfConverter>().LifeStyle.Singleton);
            container.Register(Types.FromAssemblyNamed("PDFAnnotation.Core").Pick().If(Component.IsInNamespace("PDFAnnotation.Core.Business.Models", true)).WithService.Self().Configure(c => c.LifestyleTransient()));
            container.Register(Types.FromAssemblyNamed("Esynctraining.Core").Pick().If(Component.IsInNamespace("Esynctraining.Core.Business.Models")).Unless(type => type == typeof(AuthenticationModel) || type == typeof(FullTextModel)).WithService.Self().Configure(c => c.LifestyleTransient()));

            if (web)
            {
                container.Register(Component.For <AuthenticationModel>().ImplementedBy(typeof(AuthenticationModel)).LifeStyle.PerWebRequest);
                container.Register(Component.For <XDocumentWrapper>().LifeStyle.Transient);
            }

            container.AddFacility(new LoggingFacility(LoggerImplementation.Log4net, "log4net.cfg.xml"));
        }
Exemplo n.º 36
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For <IWindsorContainer>().Instance(container));

            container.AddFacility <MassTransitFacility>(f => f.ReceiveFromUri = Keys.MassTransitReceiveFrom);
            container.AddFacility <EventStoreFacility>(f =>
            {
                f.ConnectionString = Keys.EventStoreKeyName;
                f.SqlDialect       = new PostgreSqlDialect();
            });
        }
Exemplo n.º 37
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For<IWindsorContainer>().Instance(container));

            container.AddFacility<MassTransitFacility>(f => f.ReceiveFromUri = Keys.MassTransitReceiveFrom);
            container.AddFacility<EventStoreFacility>(f =>
                                                          {
                                                              f.ConnectionString = Keys.EventStoreKeyName;
                                                              f.SqlDialect = new PostgreSqlDialect();
                                                          });
        }
Exemplo n.º 38
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));

            container.AddFacility(new StartableFacility());
            container.AddFacility<LoggingFacility>(f => f.UseNLog().WithConfig(logFileName ?? "nlog.config"));
            container.AddFacility<TypedFactoryFacility>();

            container.Register(
                Component.For<IFileSystem>().ImplementedBy<FileSystem>());
        }
        /// <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)
        {
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <ServiceFabricFacility>();

            container.Register(
                Component.For <TestStateful>().AsStatefulService("TestStatefulType", c =>
            {
                c.StateManagerConfiguration = new ReliableStateManagerConfiguration(replicatorSettingsSectionName: "TestStatefulReplicatorConfig");
            }));
        }
Exemplo n.º 40
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     //container.AddFacility<Comm100IocFacility>();
     container.AddFacility <InfrastructureIocFacility>();
     container.AddFacility <EFIocFacility>();
     container.AddFacility <ApplicationIocFacility>();
     container.Register(
         Component.For(typeof(ITenantProvider))
         .ImplementedBy(typeof(TenantProvider))
         .LifestyleScoped()
         );
 }
Exemplo n.º 41
0
        protected virtual void InitializeContainer(IWindsorContainer container)
        {
            container.AddFacility <TypedFactoryFacility>();
            container.AddFacility <DatabaseConnectionStringProviderFacility>();
            container.AddFacility <ChainOfResponsibilityFacility>();
            container.AddSupportForEmptyCollections();

            // Web API Dependency Injection
            container.Register(
                Component.For <IDependencyResolver>()
                .Instance(new WindsorDependencyResolver(Container))
                );
        }
        public static void AddComponentsTo(IWindsorContainer container, Type transactionManagerType)
        {
            ParameterCheck.ParameterRequired(container, "container");

            if (!container.Kernel.HasComponent("LogInterceptor")) {
                Core.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
                Data.CastleWindsor.ComponentRegistrar.AddComponentsTo(container, transactionManagerType);
                container.AddFacility("LogFacility", new LogFacility());
                container.AddFacility("ExceptionHandlerFacility", new ExceptionHandlerFacility());
                container.AddFacility("TransactionFacility", new TransactionFacility());
                container.AddFacility("UnitOfWorkFacility", new UnitOfWorkFacility());
            }
        }
Exemplo n.º 43
0
 /// <summary>
 /// Creates and add an IFacility facility to the container.
 /// </summary>
 /// <typeparam name="TFacility">the facility type parameter</typeparam>
 /// <param name="onCreate">on create action</param>
 /// <returns>the <see cref="IIocRegisterer"/> instance</returns>
 public IIocRegisterer AddFacility <TFacility>(Action <TFacility> onCreate = null)
     where TFacility : IFacility, new()
 {
     if (onCreate == null)
     {
         _windsorContainer.AddFacility <TFacility>();
     }
     else
     {
         _windsorContainer.AddFacility <TFacility>(onCreate);
     }
     return(this);
 }
Exemplo n.º 44
0
        public ApplicationContainer()
        {
            container = new WindsorContainer();

            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<LoggingFacility>(f => f.LogUsing(LoggerImplementation.Log4net).WithConfig("log4net.xml"));
            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));
            container.Register(Component.For<LogInterceptor>());

            container.Install(new RepositoryInstaller());
            container.Install(new PresentationInstaller());
            container.Install(new ApplicationInstaller());
        }
Exemplo n.º 45
0
        public void Init()
        {
            container = new WindsorContainer("configuration.xml");

            container.AddFacility("transactionfacility", new TransactionFacility());
            container.AddFacility("arfacility", new ActiveRecordFacility());

            container.AddComponent("blog.service", typeof(BlogService));
            container.AddComponent("post.service", typeof(PostService));
            container.AddComponent("first.service", typeof(FirstService));
            container.AddComponent("wiring.service", typeof(WiringSession));

            Recreate();
        }
Exemplo n.º 46
0
		public void Init()
		{
			container = new WindsorContainer(new XmlInterpreter(new ConfigResource()));

			container.AddFacility("transactionfacility", new TransactionFacility() );
			container.AddFacility("arfacility", new ActiveRecordFacility() );

			container.Register(Component.For<BlogService>().Named("blog.service"));
			container.Register(Component.For<PostService>().Named("post.service"));
			container.Register(Component.For<FirstService>().Named("first.service"));
			container.Register(Component.For<WiringSession>().Named("wiring.service"));

			Recreate();
		}
Exemplo n.º 47
0
		public void Init()
		{
			container = new WindsorContainer(new XmlInterpreter(new ConfigResource()));

			container.AddFacility("transactionfacility", new TransactionFacility() );
			container.AddFacility("arfacility", new ActiveRecordFacility() );

			container.AddComponent( "blog.service", typeof(BlogService) );
			container.AddComponent( "post.service", typeof(PostService) );
			container.AddComponent( "first.service", typeof(FirstService) );
			container.AddComponent( "wiring.service", typeof(WiringSession) );

			Recreate();
		}
Exemplo n.º 48
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // Facilities
            container.AddFacility<StartableFacility>(f => f.DeferredStart());
            container.AddFacility<EventWiringFacility>();
            //container.AddFacility<QuartzFacility>(); // Đã đăng ký trong CastleWindsor.xml

            // Singleton components
            container
                .Register(Component.For<INSNConfig>().ImplementedBy<NSNConfig>().LifestyleSingleton())
                .Register(Component.For<ISessionManager>().ImplementedBy<DefaultSessionManager>().LifestyleSingleton());

            NSNConfig.Instance = container.Resolve<INSNConfig>();
        }
Exemplo n.º 49
0
        public Boostrapper()
        {
            _container = new WindsorContainer();
            _container.AddFacility<LoggingFacility>(facility => facility.UseLog4Net());
            _container.AddFacility<StartableFacility>(f => f.DeferredStart());
            _container.Install(new IWindsorInstaller[]{
                new EventstoreInstaller(),
                new BusInstaller()}
            );

            Logger = _container.Resolve<ILogger>();

            Logger.DebugFormat("Started");
        }
Exemplo n.º 50
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<FactorySupportFacility>();

            container.Register(
                Component.For<ModelBinderFactoryComponentSelector, ITypedFactoryComponentSelector>(),
                Component.For<IModelBinderFactory>().AsFactory(x => x.SelectedWith<ModelBinderFactoryComponentSelector>()),
                Component.For<ISiteConfiguration>()
                    .UsingFactoryMethod(() => new DictionaryAdapterFactory()
                                                  .GetAdapter<ISiteConfiguration>(ConfigurationManager.AppSettings))

                );
        }
Exemplo n.º 51
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<TypedFactoryFacility>();
            container.AddFacility<InterceptorConventions>();

            var noSqlDBPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DynamicTranslatorDb");

            container.Register(
                Component.For<IStartupConfiguration>().ImplementedBy<StartupConfiguration>().LifeStyle.Singleton,
                Component.For<IMeanFinderFactory>().AsFactory().LifeStyle.Transient,
                Component.For<IMeanOrganizerFactory>().AsFactory().LifeStyle.Transient,
                Component.For<ILanguageDetectorFactory>().AsFactory().LifeStyle.Transient,
                Component.For(typeof (DBreezeEngine)).Instance(new DBreezeEngine(noSqlDBPath))
                );
        }
        public static IWindsorContainer Bootstrap()
        {
            if (container != null)
                return container;
            container = new WindsorContainer();
            container.AddFacility<AutoTxFacility>();
            container.Install(FromAssembly.This());
            container.Install(FromAssembly.Containing<EstimationPoint>());
            container.Register(Component.For<IWindsorContainer>().Instance(container));
            container.Register(Component.For<IControllerFactory>().ImplementedBy<WindsorControllerFactory>());

            container.AddFacility<FactorySupportFacility>();

            return container;
        }
Exemplo n.º 53
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility<SqlServerPersistenceFacility>();
            container.AddFacility<DomainServicesFacility>();
            container.AddFacility<ApplicationServicesFacility>();

            // register all Fluent Validators
            container.Register(
                //Component.For<IModelValidatorFactory>().ImplementedBy<WindsorFluentValidationValidatorFactory>().OverWrite(),
                Component.For<IFluentAdapterFactory>().ImplementedBy<DefaultFluentAdapterFactory>(),
                Classes.FromThisAssembly()
                .BasedOn(typeof(IValidator<>))
                .WithServiceBase()
                .LifestyleTransient());
        }
Exemplo n.º 54
0
 public static void AddComponentsTo(IWindsorContainer container)
 {
     Check.IsNotNull(container, "container");
     if (!container.Kernel.HasComponent("ExceptionLogger"))
     {
         container.Register(Component.For<IExceptionLogger>().ImplementedBy<ExceptionLogger>().Named("ExceptionLogger"))
         .Register(Component.For<IMethodLogger>().ImplementedBy<MethodLogger>().Named("MethodLogger"))
         .Register(Component.For<ILogFactory>().ImplementedBy<Log4netLogFactory>().Named("Log4netFactory"));
     }
     if (!container.Kernel.HasComponent("LogFacility"))
     {
         container.AddFacility("LogFacility", new LogFacility());
         container.AddFacility("ExceptionHandlerFacility", new ExceptionHandlerFacility());
     }
 }
Exemplo n.º 55
0
        /// <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)
        {
            container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
            container.Register(
                Component.For<IRepository>()
                    .ImplementedBy<GenericRepository>()
                    .DependsOn(
                        Dependency.OnValue("connectionString", ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString),
                        Dependency.OnAppSettingsValue("databaseName", "DbName")),

                Component.For<IFoodProcessor>()
                    .ImplementedBy<FoodProcessor>(),

                Component.For<IBoardProcessor>()
                    .ImplementedBy<BoardProcessor>()
                    .DynamicParameters((DynamicParametersDelegate)GetBoardTemplates),

                Component.For<BoardTemplate>()
                    .ImplementedBy<DailyMenuBoardTemplate>()
                    .Named("DailyMenuBoardTemplate"),

                Component.For<BoardTemplate>()
                    .ImplementedBy<SalatsBoardTemplate>()
                    .Named("SalatsBoardTemplate"));
        }
Exemplo n.º 56
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
     container.Register(Component.For<MongoRepository>());
     container.Register(Component.For<Manager>().DependsOn(new
                                                                      {
                                                                          check = Settings.Default.checkConsole
                                                                      }));
     container.Register(
         Component.For<TextReader>().UsingFactoryMethod<TextReader>(
         () =>
             {
                 var fs = new FileStream("in.txt", FileMode.OpenOrCreate);
                 return new StreamReader(fs);
             }));
     container.Register(
         Component.For<TextWriter>().UsingFactoryMethod<TextWriter>(
             () =>
                 {
                     var fs = new FileStream("out.txt", FileMode.OpenOrCreate);
                     return new StreamWriter(fs);
                 }));
     container.Register(Component.For<IRepository<CashpointState>>().UsingFactoryMethod(() => new MongoRepository(new MongoClient(Settings.Default.connectionString))));
     container.Register(Component.For<Cashpoint>()
                         .UsingFactoryMethod<Cashpoint>(
                             () =>
                                 {
                                     var repository = container.Resolve<IRepository<CashpointState>>();
                                     var banknotes = repository.GetContents();
                                     return new Cashpoint(Settings.Default.LimitForSmallInput > 5000, banknotes == null ? new Dictionary<uint, uint>() : banknotes.Bank.ToDictionary(pair => pair.Key, pair => pair.Value), container.Resolve<ILogger>());
                                 }));
 }
 /// <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)
 {
     container.Register(AllTypes.FromAssemblyContaining<NHibernateInstaller>().BasedOn(typeof(IConvention)));
     container.Register(Component.For<IBootstrapperTask>().ImplementedBy<ConfigureNHibernateFacility>());
     container.AddFacility<TransactionFacility>();
     container.Register(Component.For<ITransactionManager>().ImplementedBy<DefaultTransactionManager>());
 }
Exemplo n.º 58
0
        protected override void Install(IWindsorContainer container, IConfigurationStore store, FromTypesDescriptor allLoadedTypes)
        {
            container.AddFacility<TypedFactoryFacility>();
            //IsDefault composti'lerde zaten oluyor olmalı
            //Composite lerde from interface yettmiyor, all interfaces yap bari :( ya da explicit olarak şu interface diye söyle.

            container.Register(
                Compositor
                    .Of<IDefaultSessionProvider>()
                    .In(allLoadedTypes)
                    .ImplementedBy<CompositeDefaultSessionProvider>()
                    .IsDefault(),

                Compositor
                    .Of<IDefaultSessionAliasProvider>()
                    .In(allLoadedTypes)
                    .ImplementedBy<ChainedSessionAliasProvider>()
                    .IsDefault(),

                allLoadedTypes
                    .BasedOn<ISession>()
                    .WithService
                    .Self()
                    //.LifestyleCustom<SessionLifeStyleManager>()
                    .LifestyleScoped<ScopeAccessor>()
                    .Configure (registration => registration.UsingFactoryMethod(BuildSession)),

                Component
                    .For<ISessionLifeStyleProvider>()
                    .ImplementedBy<DefaultSessionLifeStyleProvider>()
                    .IsFallback()
            );
        }
		public void SetUp()
		{
			application = new Application();

			uncaughtException = null;
			container = new WindsorContainer();

			container.AddFacility<SynchronizeFacility>()
				.Register(Component.For<SynchronizationContext>(),
						  Component.For<AsynchronousContext>(),
						  Component.For<DummyWindow>().Named("Dummy").Activator<DummyFormActivator>(),
						  Component.For<IDummyWindow>().ImplementedBy<DummyWindow>(),
						  Component.For<ClassUsingWindowInWindowsContext>(),
						  Component.For<ClassUsingWindowInAmbientContext>(),
						  Component.For(typeof(IClassUsingDepedenecyContext<>)).ImplementedBy(typeof(ClassUsingDispatcherContext<>)),
						  Component.For<IWorker>().ImplementedBy<SimpleWorker>(),
						  Component.For<IWorkerWithOuts>().ImplementedBy<AsynchronousWorker>(),
						  Component.For<ManualWorker>()
						  );

			var componentNode = new MutableConfiguration("component");
			componentNode.Attributes[Constants.SynchronizedAttrib] = "true";
			var synchronizeNode = new MutableConfiguration("synchronize");
			synchronizeNode.Attributes["contextType"] = typeof(DispatcherSynchronizationContext).AssemblyQualifiedName;
			var doWorkMethod = new MutableConfiguration("method");
			doWorkMethod.Attributes["name"] = "DoWork";
			doWorkMethod.Attributes["contextType"] = typeof(DispatcherSynchronizationContext).AssemblyQualifiedName;
			synchronizeNode.Children.Add(doWorkMethod);
			componentNode.Children.Add(synchronizeNode);

			container.Kernel.ConfigurationStore.AddComponentConfiguration("class.needing.context", componentNode);
			container.Register(Component.For<ClassUsingWindow>().Named("class.needing.context"));
		}
Exemplo n.º 60
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // in proc bus
            //var bus = new InProcessBus(container);
            //container.Register(Component.For<IBus>().Instance(bus));

            // for factory
            if (!container.Kernel.GetFacilities()
                .Any(x => x.GetType().Equals(typeof(TypedFactoryFacility))))
                container.AddFacility<TypedFactoryFacility>();

            // masstransit bus
            //var busAdapter = new MassTransitPublisher(bus);

            container.Register(
                Component.For<IServiceBus>()
                    .UsingFactoryMethod(() => ServiceBusFactory.New(sbc =>
                    {
                        sbc.UseRabbitMq();
                        sbc.ReceiveFrom(_EndpointUri);
                        sbc.UseRabbitMqRouting();
                        sbc.Subscribe(c => c.LoadFrom(container));
                    })).LifeStyle.Singleton,
                Component.For<IBus>()
                    .UsingFactoryMethod((k, c) =>
                        new MassTransitPublisher(k.Resolve<IServiceBus>()))
                    .Forward<IDispatchCommits>()
                    .LifeStyle.Singleton);
        }