Esempio n. 1
0
        public void Execute()
        {
            var container = new WindsorContainer();
            //container.Kernel.ComponentModelBuilder.RemoveContributor(
            //    container.Kernel.ComponentModelBuilder.Contributors.OfType<PropertiesDependenciesModelInspector>().Single());
            //container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();
            //container.AddFacility<EventAggregatorFacility>();
            container.Register
                (
                    Component.For<IWindsorContainer>().Instance(container),
                    Component.For<IViewManager>().ImplementedBy<ViewManager>().LifestyleSingleton(),
                    Component.For<IRMSController>().ImplementedBy<RMSController>().LifestyleSingleton(),
                    Component.For<IEventPublisher>().ImplementedBy<EventPublisher>().LifestyleBoundTo<IService>(),
                    Classes.FromThisAssembly().BasedOn<IView>().WithService.FromInterface().LifestyleTransient(),
                    Classes.FromAssemblyNamed("BTE.RMS.Presentation.Logic.WPF")
                        .BasedOn<WorkspaceViewModel>()
                        .LifestyleTransient(),
                    Classes.FromAssemblyNamed("BTE.RMS.Presentation.Logic.WPF")
                        .BasedOn<IService>()
                        .WithService.FromInterface()
                        .LifestyleSingleton(),
                    Classes.FromAssemblyNamed("BTE.RMS.Presentation.Persistence.WPF")
                        .BasedOn<IRepository>()
                        .WithService.FromInterface()
                        .LifestyleBoundToNearest<IService>()
                );
            var locator = new WindsorServiceLocator(container);
            ServiceLocator.SetLocatorProvider(() => locator);

            RMSClientConfig.BaseApiSiteAddress = "http://localhost:9461/";
        }
 public void SetUp()
 {
     _mapStorage.Clear();
     _mockAccountFactory = new MockAccountFactory(_mapStorage);
     WindsorServiceLocator locator=new WindsorServiceLocator(_container=new WindsorContainer());
     _container.Register(Component.For(typeof (IAccountFactory)).UsingFactoryMethod(() => _mockAccountFactory));
     ServiceLocator.SetLocatorProvider(()=>locator);
 }
Esempio n. 3
0
        public void Execute()
        {
            //create container and locator
            var container = new WindsorContainer();
            container.Register(Component.For<IWindsorContainer>().Instance(container).LifestyleSingleton());
            var serviceLocator = new WindsorServiceLocator(container);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);

            //register areas, filters, routes, boundles
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //register data container and repositories
            //DataAccessConfigHelper.ConfigureContainer<PerHttpContextUnitOfWorkScope, DataContainer>(container,
            //   () =>
            //   {
            //       var ctx = new DataContainer();
            //       return ctx;
            //   });

            //
            //register api controllers
            container.Register(Classes.FromThisAssembly()
                                   .BasedOn<ApiController>()
                                   .WithService.Self()
                                   .LifestyleTransient());
            //register controllers
            container.Register(Classes.FromThisAssembly()
                                   .BasedOn<Controller>()
                                   .WithService.Self()
                                   .LifestyleTransient());

            //run DataBootstrapper
            //(new DataBootstrapper()).Execute();

            ////run ApplicationBootstrapper
            //(new ApplicationBootstrapper()).Execute();

            ////run facadeBootstrapper
            //(new FacadeBootstrapper()).Execute();

            //set default resolver
            System.Web.Mvc.IDependencyResolver resolver = new MITD.Core.IocDependencyResolver();
            DependencyResolver.SetResolver(resolver);
            GlobalConfiguration.Configuration.DependencyResolver = resolver.ToServiceResolver();

            //}
            //catch (Exception EX)
            //{

            //    throw EX;
            //}
        }
        public static WindsorServiceLocator Configure()
        {
            var container = new WindsorContainer();
            container.Install(FromAssembly.This());

            var serviceLocator = new WindsorServiceLocator(container.Kernel);
            //            container.Kernel.Register(Component.For<IServiceLocator>().Instance(serviceLocator).LifestyleSingleton());

            return serviceLocator;
        }
        protected override void ConfigureApplicationContainer(IWindsorContainer container)
        {
            container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
            container.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IRequestHandler<,>)).Unless(x => x == typeof(SampleFileRequestHandler)).WithServiceAllInterfaces().LifestyleScoped<NancyPerWebRequestScopeAccessor>());
            container.Register(Component.For<IRequestHandler<SampleFileRequest, Unit>>().ImplementedBy<SampleFileRequestHandler>().LifestyleTransient());
            container.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IAsyncRequestHandler<,>)).WithServiceAllInterfaces().LifestyleScoped<NancyPerWebRequestScopeAccessor>());

            container.Register(Component.For<RequestTypeProvider>().LifestyleSingleton());

            var serviceLocator = new WindsorServiceLocator(container);
            var serviceLocatorProvider = new ServiceLocatorProvider(() => serviceLocator);
            container.Register(Component.For<ServiceLocatorProvider>().Instance(serviceLocatorProvider));
        }
Esempio n. 6
0
        private static IMediator BuildMediator()
        {
            var container = new WindsorContainer();
            container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
            container.Register(Classes.FromAssemblyContaining<Ping>().Pick().WithServiceAllInterfaces());
            container.Register(Component.For<TextWriter>().Instance(Console.Out));
            container.Kernel.AddHandlersFilter(new ContravariantFilter());

            var serviceLocator = new WindsorServiceLocator(container);
            var serviceLocatorProvider = new ServiceLocatorProvider(() => serviceLocator);
            container.Register(Component.For<ServiceLocatorProvider>().Instance(serviceLocatorProvider));

            var mediator = container.Resolve<IMediator>();

            return mediator;
        }
Esempio n. 7
0
        public void Execute()
        {

            var container = new WindsorContainer().Install(FromAssembly.This());

            GlobalConfiguration.Configuration.Services.Replace(
                typeof(IHttpControllerActivator),
                new WindsorControllerActivator(container.Kernel));

            var locator = new WindsorServiceLocator(container);
            ServiceLocator.SetLocatorProvider(() => locator);

            var securityContext = new AuthContext();
            securityContext.Database.Initialize(true);

            var context = new RMSContext();
            context.Database.Initialize(true);
        }
        public RepositoryBaseTest()
        {
            _container = new WindsorContainer();

            NoTrackingReleasePolicy policy = new NoTrackingReleasePolicy();

            _container.Kernel.ReleasePolicy = policy;

            _container.Register(Component
                   .For<IObjectContextManager>()
                   .ImplementedBy<ObjectContextManager>()
                   .Named("ObjectContextManager")
                   .LifeStyle.Transient);

            _windsorServiceLocator = new WindsorServiceLocator(_container);

            ServiceLocator.SetLocatorProvider(() => _windsorServiceLocator);
        }
 public void TestRegisterAndRetrieveAllByType()
 {
     WindsorContainer container = new WindsorContainer();
     WindsorServiceLocator locator = new WindsorServiceLocator(container);
     ServiceLocator.SetLocatorProvider(() => locator);
     Assert.IsNotNull(ServiceLocator.Current);
     Assert.IsTrue(ReferenceEquals(locator, ServiceLocator.Current));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplOne)).Named("Impl1One"));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplTwo)).Named("Impl2One"));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplTwo)).Named("Impl2Two"));
     container.Register(Component.For(typeof(IAnotherTypeInterface)).ImplementedBy(typeof(AnoterImpl)).Named("AnotherImplOne"));
     container.Register(Component.For(typeof(IAnotherTypeInterface)).ImplementedBy(typeof(AnoterImpl)).Named("AnotherImplWho"));
     IEnumerable<ITypeInterface> instances=ServiceLocator.Current.GetAllInstances<ITypeInterface>();
     Assert.IsNotNull(instances);
     Assert.AreEqual(3,instances.Count());
     IEnumerable<IAnotherTypeInterface> otherInstances = ServiceLocator.Current.GetAllInstances<IAnotherTypeInterface>();
     Assert.IsNotNull(otherInstances);
     Assert.AreEqual(2,otherInstances.Count());
 }
Esempio n. 10
0
        protected void Application_Start()
        {
            windsorContainer = new WindsorContainer();

            windsorContainer.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
            windsorContainer.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IRequestHandler<,>)).WithServiceAllInterfaces().LifestylePerWebRequest());
            windsorContainer.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IAsyncRequestHandler<,>)).WithServiceAllInterfaces().LifestylePerWebRequest());

            //windsorContainer.Kernel.AddHandlersFilter(new ContravariantFilter());

            windsorContainer.Register(Component.For<RequestTypeProvider>().LifestyleSingleton());

            var serviceLocator = new WindsorServiceLocator(windsorContainer);
            var serviceLocatorProvider = new ServiceLocatorProvider(() => serviceLocator);
            windsorContainer.Register(Component.For<ServiceLocatorProvider>().Instance(serviceLocatorProvider));

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(new WebApiConfig(windsorContainer).Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var container = new WindsorContainer();

            container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
            container.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IRequestHandler<,>)).WithServiceAllInterfaces().LifestyleScoped());
            container.Register(Classes.FromAssemblyContaining<MyRequestHandler>().BasedOn(typeof(MediatR.IAsyncRequestHandler<,>)).WithServiceAllInterfaces().LifestyleScoped());

            container.Register(Component.For<RequestTypeProvider>().LifestyleSingleton());

            var serviceLocator = new WindsorServiceLocator(container);
            var serviceLocatorProvider = new ServiceLocatorProvider(() => serviceLocator);
            container.Register(Component.For<ServiceLocatorProvider>().Instance(serviceLocatorProvider));

            using (WebApp.Start(Settings.Default.Host, appBuilder => {
                appBuilder.Use<DependencyResolverScopeMiddleware>(container);
                new Startup(container.Resolve<IMediator>(), container.Resolve<RequestTypeProvider>()).Configuration(appBuilder);
            }))
            {
                Console.WriteLine("OWIN host currently listening at {0}", Settings.Default.Host);
                Console.ReadLine();
            }
        }
Esempio n. 12
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 1000;
            ThreadPool.SetMinThreads(100, 100);

            var container      = new WindsorContainer();
            var serviceLocator = new WindsorServiceLocator(container);

            _configurationValueProvider = new AzureConfigurationValueProvider();
            var storageConnectionString    = _configurationValueProvider.GetValue(ConfigurationKeys.TableStorageConnectionString);
            var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString);

            container.Register(

                Component.For <Orchestrator>()
                .ImplementedBy <Orchestrator>()
                .LifestyleSingleton(),
                Component.For <MasterScheduler>()
                .ImplementedBy <MasterScheduler>()
                .LifestyleSingleton(),
                Component.For <IConfigurationValueProvider>()
                .Instance(_configurationValueProvider),
                Component.For <IServiceLocator>()
                .Instance(serviceLocator),
                Component.For <IActorConfiguration>()
                .Instance(
                    ActorDescriptors.FromAssemblyContaining <PeckSourceScheduled>()
                    .ToConfiguration()),
                Component.For <IFactoryActor>()
                .ImplementedBy <FactoryActor>()
                .LifestyleTransient(),
                Component.For <PeckSourceProcessor>()
                .ImplementedBy <PeckSourceProcessor>()
                .LifestyleTransient(),
                Component.For <ILockStore>()
                .Instance(new AzureLockStore(new BlobSource()
            {
                ConnectionString = storageConnectionString,
                ContainerName    = "locks",
                Path             = "woodpecker/locks/master_Keys/"
            })),
                Component.For <IEventQueueOperator>()
                .Instance(new ServiceBusOperator(servicebusConnectionString))

                );

            _orchestrator = container.Resolve <Orchestrator>();
            _scheduler    = container.Resolve <MasterScheduler>();

            Task.Run(() => _orchestrator.SetupAsync()).Wait();
            _orchestrator.Start();

            Console.WriteLine("Working ...");


            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            bool result = base.OnStart();

            Trace.TraceInformation("Woodpecker.Worker.Role has been started");

            return(result);
        }
 public void GivenIHaveAWindsorServiceLocator()
 {
     IServiceLocator serviceLocator = new WindsorServiceLocator();
     UseThisServiceLocator(serviceLocator);
 }
Esempio n. 14
0
 public void TestRegisterContainer()
 {
     WindsorContainer container=new WindsorContainer();
     WindsorServiceLocator locator=new WindsorServiceLocator(container);
     ServiceLocator.SetLocatorProvider(()=>locator);
     Assert.IsNotNull(ServiceLocator.Current);
     Assert.IsTrue(ReferenceEquals(locator,ServiceLocator.Current));
 }
Esempio n. 15
0
        public void Execute()
        {
            #region create WindsorContainer and Locator

            var container = new WindsorContainer();
            container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();

            container.Register(Component.For<IWindsorContainer>().Instance(container).LifestyleSingleton());
            var serviceLocator = new WindsorServiceLocator(container);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);

            #endregion

            #region register areas, filters, routes, boundles
            AreaRegistration.RegisterAllAreas();

            container.Register(
              Component.For<IApplicationLogger>()
              .ImplementedBy<ApplicationLogger>().
                  LifestyleSingleton());

            container.Register(
                Component.For<IFuelApplicationExceptionAdapter>()
                .ImplementedBy<FuelApplicationExceptionAdapter>().
                    LifestyleSingleton());

            container.Register(
                        Component.For<GlobalExceptionHandlingAttribute>()
                        .ImplementedBy<GlobalExceptionHandlingAttribute>().
                            LifestyleSingleton());

            #endregion

            #region register data container and repositories
            DataAccessConfigHelper.ConfigureContainer<PerHttpContextUnitOfWorkScope, DataContainer>(container,
               () =>
               {
                   var connectionString = ConfigurationManager.ConnectionStrings["DataContainer"];
                   var ctx = new DataContainer(connectionString.ConnectionString);
                   return ctx;
               });

            #endregion

            #region register MVC

            //register api controllers
            container.Register(Classes.FromThisAssembly()
                                   .BasedOn<ApiController>()
                                   .WithService.Self()
                                   .LifestyleTransient());
            //register controllers
            container.Register(Classes.FromThisAssembly()
                                   .BasedOn<Controller>()
                                   .WithService.Self()
                                   .LifestyleTransient());
            #endregion

            #region register IdGenerator

            //container.Register(Component.For<IOrderFactory>().ImplementedBy<OrderFactory>().LifestyleSingleton());

            #endregion

            var fromAssemblyDescriptor = Classes.FromAssemblyInDirectory(new AssemblyFilter("bin", "*Fuel*"));

            // factory
            container.Register(fromAssemblyDescriptor
                       .BasedOn(typeof(IFactory))
                       .WithService.FromInterface()
                       .LifestyleTransient());

            container.Register(fromAssemblyDescriptor
                       .BasedOn(typeof(ICodeGenerator))
                       .WithService.FromInterface()
                       .LifestyleTransient());

            container.Register(fromAssemblyDescriptor
                       .BasedOn(typeof(IEntityConfigurator<>))
                       .WithService.FromInterface()
                       .LifestyleTransient());

            // eventNotifier
            container.Register(fromAssemblyDescriptor
                       .BasedOn(typeof(IEventNotifier))
                       .WithService.FromInterface()
                       .LifestyleTransient());

            #region register AntiCorruption
            //adapters
            container.Register(fromAssemblyDescriptor
                                   .BasedOn(typeof(IAntiCorruptionAdapter))
                                   .WithService.FromInterface()
                                   .LifestyleTransient());

            //ServiceWrapper
            container.Register(fromAssemblyDescriptor
                                  .BasedOn(typeof(IAntiCorruptionServiceWrapper))
                                   .WithServiceAllInterfaces()
                // .WithService.FromInterface()
                                   .LifestyleTransient());

            //mappers
            container.Register(fromAssemblyDescriptor
                                   .BasedOn(typeof(IMapper))
                                      .WithService.FromInterface()
                                   .LifestyleTransient());

            #endregion

            #region register Application

            container.Register(fromAssemblyDescriptor
                                 .BasedOn<IApplicationService>()
                                 .WithServiceFromInterface()
                                 .LifestyleTransient());

            #endregion

            #region register Facade

            container.Register(

                fromAssemblyDescriptor
                    .BasedOn(typeof(IFacadeService))
                    .WithServiceFromInterface().LifestyleTransient());

            container.Register(
                Component.For<IFacadeService>().
                Interceptors(InterceptorReference.ForType<SecurityInterception>())
               .Anywhere, Component.For<SecurityInterception>());
            container.Register(
                Component.For<ISecurityServiceChecker>()
                .ImplementedBy<SecurityServiceChecker>()
                .LifestyleTransient());

            #endregion

            // Log
            container.Register(
               Component.For<ILoggerService>().ImplementedBy<DbLoggerService>().Named("DB").LifeStyle.Transient,
               Component.For<ILoggerService>().ImplementedBy<FileLoggerService>().Named("File").LifeStyle.Transient

               );

            //externalHostAddressHelper
            container.Register(Component.For<ExternalHostAddressHelper>()
                                   .ImplementedBy<ExternalHostAddressHelper>()
                                   .LifestyleTransient());

            //domainServices
            container.Register(
            fromAssemblyDescriptor

                                   .BasedOn(typeof(IDomainService<>))
                                   .WithServiceAllInterfaces()
                                   .LifestyleTransient());
            container.Register(
            fromAssemblyDescriptor

                                   .BasedOn(typeof(IDomainService))
                                   .WithServiceAllInterfaces()
                                   .LifestyleTransient());

            var assemblyDescriptor = Classes.FromAssemblyInDirectory(new AssemblyFilter("bin", "*AutomaticVoucher*"));
            container.Register(assemblyDescriptor
                              .BasedOn<IAutomaticVoucher>()
                              .WithServiceFromInterface()
                              .LifestyleTransient());

            #region register Repositories
            container.Register(Component.For(typeof(MITD.Domain.Repository.IRepository<>))
                                   .ImplementedBy(typeof(EFRepository<>))
                                   .LifestyleTransient());

            container.Register(
              fromAssemblyDescriptor
                                   .BasedOn<MITD.Domain.Repository.IRepository>()
                                   .WithServiceFromInterface()
                                   .LifestyleTransient());

            #endregion

            #region excute Bootstrapper
            foreach (var bootstrapper in this.GetBootstrappers())
            {
                bootstrapper.Execute();
            }
            #endregion

            #region set default resolver
            System.Web.Mvc.IDependencyResolver resolver = new MITD.Core.IocDependencyResolver();
            DependencyResolver.SetResolver(resolver);
            GlobalConfiguration.Configuration.DependencyResolver = resolver.ToServiceResolver();
            #endregion

            container.Register(Component.For<IEventPublisher>().ImplementedBy<EventPublisher>().LifeStyle.Transient);

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Buffer the Unit of Measure and Currencies data into the Application.
            //container.Resolve<IUnitOfMeasuresAndCurrenciesFacadeService>().Reload();
            UnitOfMeasuresAndCurrenciesRegsitrar.ReloadData();
        }
Esempio n. 16
0
 public void TestRegisterTypeRetrieveType()
 {
     WindsorContainer container = new WindsorContainer();
     WindsorServiceLocator locator = new WindsorServiceLocator(container);
     ServiceLocator.SetLocatorProvider(() => locator);
     Assert.IsNotNull(ServiceLocator.Current);
     Assert.IsTrue(ReferenceEquals(locator, ServiceLocator.Current));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplOne)));
     ITypeInterface instance = ServiceLocator.Current.GetInstance<ITypeInterface>();
     Assert.IsNotNull(instance);
 }
Esempio n. 17
0
 public void TestRegisterMultipleTypesRetrieveTypeByName()
 {
     WindsorContainer container = new WindsorContainer();
     WindsorServiceLocator locator = new WindsorServiceLocator(container);
     ServiceLocator.SetLocatorProvider(() => locator);
     Assert.IsNotNull(ServiceLocator.Current);
     Assert.IsTrue(ReferenceEquals(locator, ServiceLocator.Current));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplOne)).Named("Impl1One"));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplTwo)).Named("Impl2One"));
     container.Register(Component.For(typeof(ITypeInterface)).ImplementedBy(typeof(TypeImplTwo)).Named("Impl2Two"));
     ITypeInterface instance = ServiceLocator.Current.GetInstance<ITypeInterface>();
     Assert.IsNotNull(instance);
     instance = ServiceLocator.Current.GetInstance<ITypeInterface>("Impl1One");
     Assert.IsNotNull(instance);
     ITypeInterface otehrInstance = ServiceLocator.Current.GetInstance<ITypeInterface>("Impl1One");
     Assert.IsNotNull(otehrInstance);
     Assert.IsTrue(ReferenceEquals(instance,otehrInstance));
     instance = ServiceLocator.Current.GetInstance<ITypeInterface>("Impl2One");
     Assert.IsNotNull(instance);
     otehrInstance = ServiceLocator.Current.GetInstance<ITypeInterface>("Impl2Two");
     Assert.IsNotNull(otehrInstance);
     Assert.IsFalse(ReferenceEquals(instance,otehrInstance));
 }
Esempio n. 18
0
 public void Setup()
 {
     WindsorServiceLocator locator = new WindsorServiceLocator(_container = new WindsorContainer());
     ServiceLocator.SetLocatorProvider(() => locator);
 }
Esempio n. 19
0
        private void ConfigureContainer()
        {
            _container = new WindsorContainer();
            _container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());

            _container.Register(Component.For<HttpClient>().UsingFactoryMethod(() => {
                var httpClient = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true });
                httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
                return httpClient;
            }).LifestyleSingleton());

            var mediatorLocation = (MediatorLocation)Enum.Parse(typeof(MediatorLocation), Settings.Default.MediatorLocation);
            var mediatorProtocol = (MediatorProtocol)Enum.Parse(typeof(MediatorProtocol), Settings.Default.MediatorProtocol);

            if (mediatorLocation == MediatorLocation.Local)
            {
                //in-proc handlers
                _container.Register(Classes.FromAssemblyContaining<MyRequestHandler>().Pick().WithServiceAllInterfaces());
            }
            else
            {
                switch(mediatorProtocol)
                {
                    case MediatorProtocol.Http:
                        //generic web api remote handler
                        _container.Register(Component.For(typeof(IRequestHandler<,>)).ImplementedBy(typeof(GenericWebApiRemoteHandler<,>)).LifestylePerWebRequest());
                        _container.Register(Component.For(typeof(IAsyncRequestHandler<,>)).ImplementedBy(typeof(AsyncGenericWebApiRemoteHandler<,>)).LifestylePerWebRequest());
                        break;
                    case MediatorProtocol.WCF:
                        _container.Kernel.AddFacility<WcfFacility>();
                        _container.Register(Component.For<IRequestHandlerService>()
                                   .AsWcfClient(new DefaultClientModel
                                   {
                                       Endpoint = WcfEndpoint.BoundTo(new NetTcpBinding() { TransferMode = TransferMode.Streamed })
                                           .At(Settings.Default.BackEndServiceUri)
                                   }).LifestylePerWebRequest());
                        //wcf remote handler
                        _container.Register(Component.For(typeof(IRequestHandler<,>)).ImplementedBy(typeof(GenericWcfRemoteHandler<,>)).LifestylePerWebRequest());
                        _container.Register(Component.For(typeof(IAsyncRequestHandler<,>)).ImplementedBy(typeof(AsyncGenericWcfRemoteHandler<,>)).LifestylePerWebRequest());
                        break;
                }
            }

            _container.Kernel.AddHandlersFilter(new ContravariantFilter());

            var serviceLocator = new WindsorServiceLocator(_container);
            var serviceLocatorProvider = new ServiceLocatorProvider(() => serviceLocator);
            _container.Register(Component.For<ServiceLocatorProvider>().Instance(serviceLocatorProvider));

            //BootstrapControllers
            _container.Register(Classes.FromThisAssembly().BasedOn<IController>().LifestyleTransient());
        }
Esempio n. 20
0
        public static void SetupDi(IWindsorContainer container,
                                   IConfigurationValueProvider configurationValueProvider,
                                   IPulser[] pulsers)
        {
            var serviceLocator = new WindsorServiceLocator(container);

            container.Register(

                Component.For <Orchestrator>()
                .ImplementedBy <Orchestrator>()
                .LifestyleTransient(),

                Component.For <IActorConfiguration>()
                .Instance(
                    ActorDescriptors.FromAssemblyContaining <ImportFileProcessed>()
                    .ToConfiguration()),

                Component.For <IServiceLocator>()
                .Instance(serviceLocator),

                Component.For <IPulser[]>()
                .Instance(pulsers),

                Component.For <PulserPublisher>()
                .ImplementedBy <PulserPublisher>()
                .LifestyleSingleton(),

                Component.For <IFactoryActor>()
                .ImplementedBy <FactoryActor>()
                .LifestyleTransient(),

                Component.For <IConfigurationValueProvider>()
                .Instance(configurationValueProvider),

                Component.For <IEventQueueOperator>()
                .ImplementedBy <ServiceBusOperator>()
                .DynamicParameters((k, dic)
                                   =>
            {
                dic["connectionString"] = configurationValueProvider.GetValue(
                    "BusConnectionString");
            })
                .LifestyleSingleton(),

                Component.For(typeof(ICollectionStore <>))
                .ImplementedBy(typeof(AzureCollectionStore <>))
                .DynamicParameters((k, dic)
                                   =>
            {
                dic["connectionString"] = configurationValueProvider.GetValue("StorageConnectionString");
            })
                .LifestyleSingleton(),

                //Component.For(typeof(IKeyValueStore))
                //.ImplementedBy(typeof(AzureKeyValueStore))
                // .DynamicParameters((k, dic)
                //        =>
                // {
                //     dic["connectionString"] = configurationValueProvider.GetValue("StorageConnectionString");
                //     dic["bucketName"] = "feeds";
                // })
                //.LifestyleSingleton(),

                Component.For(typeof(IDynamoStore))
                .ImplementedBy(typeof(AzureKeyValueStore))
                .DynamicParameters((k, dic)
                                   =>
            {
                dic["connectionString"] = configurationValueProvider.GetValue("StorageConnectionString");
                dic["bucketName"]       = "feeds";
            })
                .LifestyleSingleton(),

                Classes.FromAssemblyContaining <ImportFileProcessed>()
                .Pick()

                );
        }
Esempio n. 21
0
        protected static void Setup()
        {
            var container      = new WindsorContainer();
            var serviceLocator = new WindsorServiceLocator(container);

            _configurationValueProvider = new AppSettingsConfigProvider();
            var storageConnectionString    = _configurationValueProvider.GetValue(ConfigurationKeys.StorageConnectionString);
            var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString);

            container.Register(
                Component.For <IElasticsearchClient>()
                .ImplementedBy <ElasticsearchClient>()
                .LifestyleSingleton(),
                Component.For <Orchestrator>()
                .ImplementedBy <Orchestrator>()
                .LifestyleSingleton(),
                Component.For <MasterScheduler>()
                .ImplementedBy <MasterScheduler>()
                .LifestyleSingleton(),
                Component.For <IConfigurationValueProvider>()
                .Instance(_configurationValueProvider),
                Component.For <ISourceConfiguration>()
                .ImplementedBy <TableStorageConfigurationSource>(),
                Component.For <IServiceLocator>()
                .Instance(serviceLocator),
                Component.For <IActorConfiguration>()
                .Instance(
                    ActorDescriptors.FromAssemblyContaining <ShardRangeActor>()
                    .ToConfiguration()),
                Component.For <IFactoryActor>()
                .ImplementedBy <FactoryActor>()
                .LifestyleTransient(),
                Component.For <IHttpClient>()
                .ImplementedBy <DefaultHttpClient>()
                .LifestyleSingleton(),
                Component.For <ShardKeyActor>()
                .ImplementedBy <ShardKeyActor>()
                .LifestyleTransient(),
                Component.For <ShardRangeActor>()
                .ImplementedBy <ShardRangeActor>()
                .LifestyleTransient(),
                Component.For <BlobFileActor>()
                .ImplementedBy <BlobFileActor>()
                .LifestyleTransient(),
                Component.For <IisBlobScheduler>()
                .ImplementedBy <IisBlobScheduler>()
                .LifestyleTransient(),
                Component.For <RangeShardKeyScheduler>()
                .ImplementedBy <RangeShardKeyScheduler>()
                .LifestyleTransient(),
                Component.For <MinuteTableShardScheduler>()
                .ImplementedBy <MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <ReverseTimestampMinuteTableShardScheduler>()
                .ImplementedBy <ReverseTimestampMinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <IisLogParser>()
                .ImplementedBy <IisLogParser>()
                .LifestyleTransient(),
                Component.For <IElasticsearchBatchPusher>()
                .ImplementedBy <ElasticsearchBatchPusher>()
                .LifestyleTransient()
                .DependsOn(Dependency.OnValue("esUrl", _configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl))),
                Component.For <ILockStore>()
                .Instance(new AzureLockStore(new BlobSource()
            {
                ConnectionString = storageConnectionString,
                ContainerName    = "locks",
                Path             = "conveyor_belt/locks/master_Keys/"
            })),
                Component.For <IEventQueueOperator>()
                .Instance(new ServiceBusOperator(servicebusConnectionString))

                );

            _orchestrator = container.Resolve <Orchestrator>();
            _scheduler    = container.Resolve <MasterScheduler>();
        }
Esempio n. 22
0
        public static void ConfigeLocator()
        {
            var container = new WindsorContainer();

            //container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();


            RegisterDataAccess(container);

            container.Register
            (
                Classes.FromAssemblyContaining <MITD.PMS.Application.JobService>()
                .BasedOn <IService>().If(c => c.Namespace == typeof(MITD.PMS.Application.JobService).Namespace &&
                                         c.Name != typeof(MITD.PMS.Application.CalculatorEngine).Name
                                         &&
                                         c.Name !=
                                         typeof(MITD.PMS.Application.JobIndexPointCalculator).Name)
                .WithService.FromInterface()
                .LifestyleBoundToNearest <IService>(),
                Classes.FromAssemblyContaining <FunctionService>()
                .BasedOn <IService>().If(c => c.Namespace == typeof(FunctionService).Namespace)
                .WithService.FromInterface()
                .LifestyleBoundToNearest <IService>(),
                Classes.FromAssemblyContaining <MITD.PMS.Domain.Service.RuleBasedPolicyEngineService>()
                .BasedOn <IService>().OrBasedOn(typeof(IConfigurator))
                .WithService.FromInterface()
                .LifestyleBoundToNearest <IService>(),


                Component.For <IRuleService>().ImplementedBy <RuleEngineService>()
                .LifestyleBoundToNearest <IService>(),
                Component.For <IServiceLocatorProvider>().ImplementedBy <LocatorProvider>()
                .DependsOn(new Hashtable {
                { "connectionName", "PMSDBConnection" }
            })
                .LifeStyle.BoundTo <IService>(),
                Component.For <IEventPublisher>().ImplementedBy <EventPublisher>()
                .LifestyleBoundTo <IService>(),
                Component.For <ISecurityService>().ImplementedBy <SecurityService>()
                .LifestyleBoundToNearest <IService>()
            );

            container.Register(
                Component.For <IInquiryJobIndexPointCreatorService>()
                .ImplementedBy <InquiryJobIndexPointCreatorService>()
                .LifeStyle.Transient);
            container.Register(
                Component.For <IPMSAdminService>().ImplementedBy <PMSAdminService>().LifestyleBoundTo <IService>());
            container.Register(
                Component.For <IJobPositionInquiryConfiguratorService>()
                .ImplementedBy <JobPositionInquiryConfiguratorService>()
                .LifestyleBoundTo <IService>());


            container.Register(
                Component.For <IJobIndexPointCalculatorProvider>()
                .ImplementedBy <JobIndexPointCalculatorProvider>()
                .LifeStyle.Singleton.IsDefault());

            container.Register(
                Component.For <IInquiryConfiguratorService>()
                .ImplementedBy <InquiryConfiguratorService>()
                .LifeStyle.Singleton.IsDefault());

            container.Register(
                Component.For <ICalculatorEngine>().ImplementedBy <CalculatorEngine>()
                .LifeStyle.Transient);

            container.Register(
                Component.For <IJobIndexPointCalculator>().ImplementedBy <JobIndexPointCalculator>().LifeStyle.Transient);


            var locator = new WindsorServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => locator);
        }
Esempio n. 23
0
        protected static void Setup()
        {
            var container      = new WindsorContainer();
            var serviceLocator = new WindsorServiceLocator(container);

            _configurationValueProvider = new AppSettingsConfigProvider();
            var storageConnectionString    = _configurationValueProvider.GetValue(ConfigurationKeys.StorageConnectionString);
            var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString);
            var headersText = _configurationValueProvider.GetValue(ConfigurationKeys.TabSeparatedCustomEsHttpHeaders);
            var headers     = new List <KeyValuePair <string, string> >();

            if (headersText != null)
            {
                foreach (var header in headersText.Split('\t'))
                {
                    var strings = header.Split(new[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
                    if (strings.Length == 2)
                    {
                        headers.Add(new KeyValuePair <string, string>(strings[0], strings[1]));
                    }
                }
            }

            container.Register(
                Component.For <IElasticsearchClient>()
                .ImplementedBy <ElasticsearchClient>()
                .LifestyleSingleton(),
                Component.For <Orchestrator>()
                .ImplementedBy <Orchestrator>()
                .LifestyleSingleton(),
                Component.For <MasterScheduler>()
                .ImplementedBy <MasterScheduler>()
                .LifestyleSingleton(),
                Component.For <IConfigurationValueProvider>()
                .Instance(_configurationValueProvider),
                Component.For <ISourceConfiguration>()
                .ImplementedBy <TableStorageConfigurationSource>(),
                Component.For <IServiceLocator>()
                .Instance(serviceLocator),
                Component.For <IActorConfiguration>()
                .Instance(
                    ActorDescriptors.FromAssemblyContaining <ShardRangeActor>()
                    .ToConfiguration().UpdateParallelism(_configurationValueProvider)),
                Component.For <IFactoryActor>()
                .ImplementedBy <FactoryActor>()
                .LifestyleTransient(),
                Component.For <IHttpClient>()
                .ImplementedBy <DefaultHttpClient>()
                .LifestyleSingleton()
                .DependsOn(Dependency.OnValue("defaultHeaders", headers)),
                Component.For <ShardKeyActor>()
                .ImplementedBy <ShardKeyActor>()
                .LifestyleTransient(),
                Component.For <ShardRangeActor>()
                .ImplementedBy <ShardRangeActor>()
                .LifestyleTransient(),
                Component.For <BlobFileActor>()
                .ImplementedBy <BlobFileActor>()
                .LifestyleTransient(),
                Component.For <BlobFileConventionActor>()
                .ImplementedBy <BlobFileConventionActor>()
                .LifestyleTransient(),
                Component.For <IisBlobScheduler>()
                .ImplementedBy <IisBlobScheduler>()
                .LifestyleTransient(),
                Component.For <IisBlobConventionScheduler>()
                .ImplementedBy <IisBlobConventionScheduler>()
                .LifestyleTransient(),
                Component.For <IIndexNamer>()
                .ImplementedBy <IndexNamer>()
                .LifestyleSingleton(),
                Component.For <RangeShardKeyScheduler>()
                .ImplementedBy <RangeShardKeyScheduler>()
                .LifestyleTransient(),
                Component.For <MinuteTableShardScheduler>()
                .ImplementedBy <MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <Modulo10MinuteTableShardScheduler>()
                .ImplementedBy <Modulo10MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <SimpleBlobScheduler>()
                .ImplementedBy <SimpleBlobScheduler>()
                .LifestyleTransient(),
                Component.For <ReverseTimestampMinuteTableShardScheduler>()
                .ImplementedBy <ReverseTimestampMinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <D18MinuteTableShardScheduler>()
                .ImplementedBy <D18MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <EventHubScheduler>()
                .ImplementedBy <EventHubScheduler>()
                .LifestyleTransient(),
                Component.For <InsightMetricsParser>()
                .ImplementedBy <InsightMetricsParser>()
                .LifestyleTransient(),
                Component.For <GenericJsonParser>()
                .ImplementedBy <GenericJsonParser>()
                .LifestyleTransient(),
                Component.For <IisLogParser>()
                .ImplementedBy <IisLogParser>()
                .LifestyleTransient(),
                Component.For <AkamaiLogParser>()
                .ImplementedBy <AkamaiLogParser>()
                .LifestyleTransient(),
                Component.For <NestBatchPusher>()
                .ImplementedBy <NestBatchPusher>()
                .LifestyleTransient()
                .DependsOn(Dependency.OnValue("esUrl", _configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl))),
                Component.For <ILockStore>()
                .Instance(new AzureLockStore(new BlobSource()
            {
                ConnectionString = storageConnectionString,
                ContainerName    = "locks",
                Path             = "conveyor_belt/locks/master_Keys/"
            })),
                Component.For <IKeyValueStore>()
                .Instance(new AzureKeyValueStore(storageConnectionString, "locks")),
                Component.For <IEventQueueOperator>()
                .Instance(new ServiceBusOperator(servicebusConnectionString)),
                Component.For <ITelemetryProvider>()
                .ImplementedBy <TelemetryProvider>()
                .LifestyleSingleton()
                );

            _orchestrator = container.Resolve <Orchestrator>();
            _scheduler    = container.Resolve <MasterScheduler>();

            ServicePointHelper.ApplyStandardSettings(_configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl));
        }