Ejemplo n.º 1
0
		private UnityContainer GetLocalContainer()
		{
			#region Common Settings for Web and Services

			var container = new UnityContainer();
			container.RegisterType<IKnownSerializationTypes, CatalogEntityFactory>("catalog",
																				   new ContainerControlledLifetimeManager
																					   ());

			//container.RegisterType<IKnowSerializationTypes, OrderEntityFactory>("order", new ContainerControlledLifetimeManager(), null);
			container.RegisterInstance<IConsumerFactory>(new DomainAssemblyScannerConsumerFactory(container));
			container.RegisterType<IKnownSerializationTypes, DomainAssemblyScannerConsumerFactory>("scaned",
																								   new ContainerControlledLifetimeManager
																									   (),
																								   new InjectionConstructor
																									   (container));



			container.RegisterType<IConsumerFactory, DomainAssemblyScannerConsumerFactory>();
			container.RegisterType<ISystemObserver, NullSystemObserver>();
			container.RegisterType<IEngineProcess, SingleThreadConsumingProcess>();
			container.RegisterType<IMessageSerializer, DataContractMessageSerializer>();

			container.RegisterType<IQueueWriter, InMemoryQueueWriter>();
			container.RegisterType<IQueueReader, InMemoryQueueReader>();

			container.RegisterType<IMessageSender, DefaultMessageSender>(new ContainerControlledLifetimeManager());
			container.RegisterType<ICurrencyService, CurrencyService>(new ContainerControlledLifetimeManager());

			//container.RegisterType<ICacheProvider, InMemCachingProvider>();
			container.RegisterType<ICacheRepository, HttpCacheRepository>();
			container.RegisterType<IOperationLogRepository, OperationLogContext>();
			container.RegisterType<ILogOperationFactory, LogOperationFactory>();

			//Register Sequences
			container.RegisterType<ISequenceService, SequenceService>();

			//Register Template and Email service
			container.RegisterType<ITemplateService, TemplateService>();

			container.RegisterType<IEmailService, NetEmailService>();


			#region Interceptors

			// register interceptors
			container.RegisterType<IInterceptor, AuditChangeInterceptor>("audit");
			container.RegisterType<IInterceptor, LogInterceptor>("log");
			container.RegisterType<IInterceptor, EntityEventInterceptor>("events");

			#endregion

			#region Marketing

			container.RegisterType<IMarketingRepository, EFMarketingRepository>(new InjectionConstructor(MarketingDatabaseName));
			container.RegisterType<IMarketingEntityFactory, MarketingEntityFactory>();
			container.RegisterType<IPromotionUsageProvider, PromotionUsageProvider>();
			container.RegisterType<IPromotionEntryPopulate, PromotionEntryPopulate>();

			#endregion

			//#region Search
			container.RegisterInstance<ISearchConnection>(
				new SearchConnection(
					ConnectionHelper.GetConnectionString("SearchConnectionString")));
			container.RegisterType<ISearchService, SearchService>(new HierarchicalLifetimeManager());
			container.RegisterType<ISearchIndexController, SearchIndexController>();
			container.RegisterType<IBuildSettingsRepository, EFSearchRepository>();
			container.RegisterType<ISearchEntityFactory, SearchEntityFactory>(new ContainerControlledLifetimeManager());
			container.RegisterType<ISearchProvider, FakeSarchProvider>();
			container.RegisterType<ISearchQueryBuilder, ElasticSearchQueryBuilder>();
			container.RegisterType<ISearchIndexBuilder, CatalogItemIndexBuilder>("catalogitem");

			//#endregion

			#region Assets

			container.RegisterType<IAssetEntityFactory, AssetEntityFactory>();


			// using local storage assets
			container.RegisterType<IAssetRepository, FileSystemBlobAssetRepository>();
			container.RegisterType<IBlobStorageProvider, FileSystemBlobAssetRepository>();
			container.RegisterType<IAssetUrl, FileSystemAssetUrl>();

			container.RegisterType<IAssetService, AssetService>();
			#endregion

			#region Catalog
			container.RegisterType<ICatalogEntityFactory, CatalogEntityFactory>(new ContainerControlledLifetimeManager());

			container.RegisterType<ICatalogRepository, EFCatalogRepository>(new InjectionConstructor(CatalogDatabaseName));
            container.RegisterType<ICatalogOutlineBuilder, CatalogOutlineBuilder>();
			container.RegisterType<IPricelistRepository, EFCatalogRepository>(new InjectionConstructor(CatalogDatabaseName));
			container.RegisterType<ICatalogService, CatalogService>();
			container.RegisterType<IPriceListAssignmentEvaluator, PriceListAssignmentEvaluator>();
			container.RegisterType<IPriceListAssignmentEvaluationContext, PriceListAssignmentEvaluationContext>();

			container.RegisterType<IImportJobEntityFactory, ImportJobEntityFactory>(
				new ContainerControlledLifetimeManager());
			container.RegisterType<IImportRepository, EFImportingRepository>();
			container.RegisterType<IImportService, ImportService>();
			#endregion

			#region Customer

			container.RegisterType<ICustomerEntityFactory, CustomerEntityFactory>(
				new ContainerControlledLifetimeManager());

			container.RegisterType<ICustomerRepository, EFCustomerRepository>();
			container.RegisterType<ICustomerSessionService, CustomerSessionService>();

			#endregion

			#region Inventory

			container.RegisterType<IInventoryEntityFactory, InventoryEntityFactory>(
				new ContainerControlledLifetimeManager());
			container.RegisterType<IInventoryRepository, EFInventoryRepository>();

			#endregion

			#region Order

			container.RegisterType<IOrderEntityFactory, OrderEntityFactory>(new ContainerControlledLifetimeManager());

			var activityProvider = WorkflowConfiguration.Instance.DefaultActivityProvider;
			var workflowService = new WFWorkflowService(activityProvider);
			container.RegisterInstance<IWorkflowService>(workflowService);
			container.RegisterType<IOrderStateController, OrderStateController>();

			container.RegisterType<IOrderRepository, EFOrderRepository>();
			container.RegisterType<IShippingRepository, EFOrderRepository>();
			container.RegisterType<IPaymentMethodRepository, EFOrderRepository>();
			container.RegisterType<ITaxRepository, EFOrderRepository>();

			container.RegisterType<ICountryRepository, EFOrderRepository>();
			container.RegisterType<IOrderService, OrderService>();

			#endregion

			#region Review

			container.RegisterType<IReviewEntityFactory, ReviewEntityFactory>(new ContainerControlledLifetimeManager());

			container.RegisterType<IReviewRepository, EFReviewRepository>();

			#endregion

			#region Security

			container.RegisterType<ISecurityEntityFactory, SecurityEntityFactory>(
				new ContainerControlledLifetimeManager());
			container.RegisterType<ISecurityRepository, EFSecurityRepository>();
			container.RegisterType<IUserSecurity, WebUserSecurity>();
			container.RegisterType<IAuthenticationService, AuthenticationService>();
			container.RegisterType<ISecurityService, SecurityService>();
			container.RegisterType<IOAuthWebSecurity, OAuthWebSecurityWrapper>();

			#endregion

			#region Store

			container.RegisterType<IStoreEntityFactory, StoreEntityFactory>(new ContainerControlledLifetimeManager());

			container.RegisterType<IStoreService, StoreService>();
			container.RegisterType<IStoreRepository, EFStoreRepository>(new InjectionConstructor(StoreDatabaseName));

			#endregion

			#endregion

			#region MVC Helpers

			container.RegisterType<MarketingHelper>();
			container.RegisterType<PriceListClient>();
			container.RegisterType<StoreClient>();
			container.RegisterType<CatalogClient>();
			container.RegisterType<UserClient>();
			container.RegisterType<ShippingClient>();
			container.RegisterType<PromotionClient>();
			container.RegisterType<DynamicContentClient>();
			container.RegisterType<CountryClient>();
			container.RegisterType<OrderClient>();
			container.RegisterType<DisplayTemplateClient>();
			container.RegisterType<SettingsClient>();
			container.RegisterType<SequencesClient>();
			container.RegisterType<IPaymentOption, CreditCardOption>("creditcard");

			#endregion

			#region DynamicContent

			container.RegisterType<IDynamicContentService, DynamicContentService>();
			container.RegisterType<IDynamicContentRepository, EFDynamicContentRepository>();
			container.RegisterType<IDynamicContentEvaluator, DynamicContentEvaluator>();

			#endregion

			#region AppConfig

			container.RegisterType<IAppConfigRepository, EFAppConfigRepository>(new InjectionConstructor(AppConfigDatabaseName));
			container.RegisterType<IAppConfigEntityFactory, AppConfigEntityFactory>();

			#endregion

			#region DisplayTemplates

			container.RegisterType<IDisplayTemplatesService, DisplayTemplatesService>();
			container.RegisterType<IDisplayTemplateEvaluator, DisplayTemplateEvaluator>();

			#endregion

			#region Events

			// Register event listeners
			container.RegisterType<IEntityEventListener, OrderChangeEventListener>("order");
			container.RegisterType<IEntityEventListener, PublicReplyEventListener>("customer");
			container.RegisterType<IEntityEventListener, CaseChangeEventListener>("customer");
            container.RegisterType<IEntityEventListener, ReviewApprovedEventListener>("review");
			container.RegisterType<IEntityEventContext, EntityEventContext>(new ContainerControlledLifetimeManager());

			#endregion

			#region Globalization

			//For using database resources
			container.RegisterType<IElementRepository, DatabaseElementRepository>();
			//For using Local Resources
			//container.RegisterInstance<IElementRepository>(new CacheElementRepository(new XmlElementRepository()));

			#endregion

            #region OutputCache

            container.RegisterType<IKeyBuilder, KeyBuilder>();
            container.RegisterType<IKeyGenerator, KeyGenerator>();
            container.RegisterType<IDonutHoleFiller, DonutHoleFiller>();
            container.RegisterType<ICacheHeadersHelper, CacheHeadersHelper>();
            container.RegisterType<ICacheSettingsManager, CacheSettingsManager>();
            container.RegisterType<IReadWriteOutputCacheManager, OutputCacheManager>();
            container.RegisterInstance<IActionSettingsSerialiser>(new EncryptingActionSettingsSerialiser(new ActionSettingsSerialiser(), new Encryptor()));
            container.RegisterType<ICacheService, CacheService>();

            #endregion

			container.RegisterInstance<IUnityContainer>(container);
			return container;
		}
Ejemplo n.º 2
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            #region Common Settings for Web and Services

            // this section is common for both web application and services application and should be kept identical
            var isAzure = AzureCommonHelper.IsAzureEnvironment();

            container.RegisterType<IKnownSerializationTypes, CatalogEntityFactory>("catalog",
                                                                                   new ContainerControlledLifetimeManager
                                                                                       ());

            //container.RegisterType<IKnowSerializationTypes, OrderEntityFactory>("order", new ContainerControlledLifetimeManager(), null);
            container.RegisterInstance<IConsumerFactory>(new DomainAssemblyScannerConsumerFactory(container));
            container.RegisterType<IKnownSerializationTypes, DomainAssemblyScannerConsumerFactory>("scaned",
                                                                                                   new ContainerControlledLifetimeManager
                                                                                                       (),
                                                                                                   new InjectionConstructor
                                                                                                       (container));



            container.RegisterType<IConsumerFactory, DomainAssemblyScannerConsumerFactory>();
            container.RegisterType<ISystemObserver, NullSystemObserver>();
            container.RegisterType<IEngineProcess, SingleThreadConsumingProcess>();
            container.RegisterType<IMessageSerializer, DataContractMessageSerializer>();
            if (isAzure)
            {
                container.RegisterType<IQueueWriter, AzureQueueWriter>();
                container.RegisterType<IQueueReader, AzureQueueReader>();
            }
            else
            {
                container.RegisterType<IQueueWriter, InMemoryQueueWriter>();
                container.RegisterType<IQueueReader, InMemoryQueueReader>();
            }
            container.RegisterType<IMessageSender, DefaultMessageSender>(new ContainerControlledLifetimeManager());
            container.RegisterType<ICurrencyService, CurrencyService>(new ContainerControlledLifetimeManager());

            //container.RegisterType<ICacheProvider, InMemCachingProvider>();
            container.RegisterType<ICacheRepository, HttpCacheRepository>();
            container.RegisterType<IOperationLogRepository, OperationLogContext>(new PerRequestLifetimeManager());
            container.RegisterType<ILogOperationFactory, LogOperationFactory>();

            //Register Sequences
            container.RegisterType<ISequenceService, SequenceService>();

            //Register Template and Email service
            container.RegisterType<ITemplateService, TemplateService>();

            if (isAzure)
            {
                container.RegisterType<IEmailService, AzureEmailService>();
            }
            else
            {
                container.RegisterType<IEmailService, NetEmailService>();
            }

            container.RegisterType<ICatalogOutlineBuilder, CatalogOutlineBuilder>();

            #region Interceptors

            // register interceptors
            container.RegisterType<IInterceptor, AuditChangeInterceptor>("audit");
            container.RegisterType<IInterceptor, LogInterceptor>("log");
            container.RegisterType<IInterceptor, EntityEventInterceptor>("events");

            #endregion

            #region Marketing

            container.RegisterType<IMarketingRepository, EFMarketingRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IMarketingEntityFactory, MarketingEntityFactory>();
            container.RegisterType<IPromotionUsageProvider, PromotionUsageProvider>();
            container.RegisterType<IPromotionEntryPopulate, PromotionEntryPopulate>();

            //Register prmotion evaluation policies
            container.RegisterType<IEvaluationPolicy, GlobalExclusivityPolicy>("global");
            container.RegisterType<IEvaluationPolicy, GroupExclusivityPolicy>("group");
            container.RegisterType<IEvaluationPolicy, CartSubtotalRewardCombinePolicy>("cart");
            container.RegisterType<IEvaluationPolicy, ShipmentRewardCombinePolicy>("shipment");


            container.RegisterType<IPromotionEvaluator, DefaultPromotionEvaluator>();

            #endregion

            #region Search

            var searchConnection = new SearchConnection(ConnectionHelper.GetConnectionString("SearchConnectionString"));
            container.RegisterInstance<ISearchConnection>(searchConnection);
            container.RegisterType<ISearchService, SearchService>(new HierarchicalLifetimeManager());
            container.RegisterType<ISearchIndexController, SearchIndexController>();
            container.RegisterType<IBuildSettingsRepository, EFSearchRepository>(new PerRequestLifetimeManager());
            container.RegisterType<ISearchEntityFactory, SearchEntityFactory>(new ContainerControlledLifetimeManager());
            container.RegisterType<ISearchIndexBuilder, CatalogItemIndexBuilder>("catalogitem");

            // If provider specified as lucene, use lucene libraries, otherwise use default, which is elastic search
            if (string.Equals(searchConnection.Provider, SearchProviders.Lucene.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                // Lucene Search implementation
                container.RegisterType<ISearchProvider, LuceneSearchProvider>();
                container.RegisterType<ISearchQueryBuilder, LuceneSearchQueryBuilder>();
            }
            else
            {
                container.RegisterType<ISearchProvider, ElasticSearchProvider>();
                container.RegisterType<ISearchQueryBuilder, ElasticSearchQueryBuilder>();
            }
            #endregion

            #region Assets

            container.RegisterType<IAssetEntityFactory, AssetEntityFactory>();

            // using azure assets
            if (isAzure)
            {
                container.RegisterType<IAssetRepository, AzureBlobAssetRepository>();
                container.RegisterType<IBlobStorageProvider, AzureBlobAssetRepository>();
                container.RegisterType<IAssetUrl, AzureBlobAssetRepository>();
            }
            else
            {
                // using local storage assets
                container.RegisterType<IAssetRepository, FileSystemBlobAssetRepository>();
                container.RegisterType<IBlobStorageProvider, FileSystemBlobAssetRepository>();
                container.RegisterType<IAssetUrl, FileSystemAssetUrl>();
            }

            container.RegisterType<IAssetService, AssetService>();
            #endregion

            #region Catalog
            container.RegisterType<ICatalogEntityFactory, CatalogEntityFactory>(new ContainerControlledLifetimeManager());

            container.RegisterType<ICatalogRepository, EFCatalogRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IPricelistRepository, EFCatalogRepository>(new PerRequestLifetimeManager());
            container.RegisterType<ICatalogService, CatalogService>();
            container.RegisterType<IPriceListAssignmentEvaluator, PriceListAssignmentEvaluator>();
            container.RegisterType<IPriceListAssignmentEvaluationContext, PriceListAssignmentEvaluationContext>();

            container.RegisterType<IImportJobEntityFactory, ImportJobEntityFactory>(
                new ContainerControlledLifetimeManager());
            container.RegisterType<IImportRepository, EFImportingRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IImportService, ImportService>();
            #endregion

            #region Customer

            container.RegisterType<ICustomerEntityFactory, CustomerEntityFactory>(
                new ContainerControlledLifetimeManager());

            container.RegisterType<ICustomerRepository, EFCustomerRepository>(new PerRequestLifetimeManager());
            container.RegisterType<ICustomerSessionService, CustomerSessionService>();

            #endregion

            #region Inventory

            container.RegisterType<IInventoryEntityFactory, InventoryEntityFactory>(
                new ContainerControlledLifetimeManager());
            container.RegisterType<IInventoryRepository, EFInventoryRepository>(new PerRequestLifetimeManager());

            #endregion

            #region Order

            container.RegisterType<IOrderEntityFactory, OrderEntityFactory>(new ContainerControlledLifetimeManager());

            var activityProvider = WorkflowConfiguration.Instance.DefaultActivityProvider;
            var workflowService = new WFWorkflowService(activityProvider);
            container.RegisterInstance<IWorkflowService>(workflowService);
            container.RegisterType<IOrderStateController, OrderStateController>();

            container.RegisterType<IOrderRepository, EFOrderRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IShippingRepository, EFOrderRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IPaymentMethodRepository, EFOrderRepository>(new PerRequestLifetimeManager());
            container.RegisterType<ITaxRepository, EFOrderRepository>(new PerRequestLifetimeManager());

            container.RegisterType<ICountryRepository, EFOrderRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IOrderService, OrderService>();

            #endregion

            #region Review

            container.RegisterType<IReviewEntityFactory, ReviewEntityFactory>(new ContainerControlledLifetimeManager());

            container.RegisterType<IReviewRepository, EFReviewRepository>(new PerRequestLifetimeManager());

            #endregion

            #region Security

            container.RegisterType<ISecurityEntityFactory, SecurityEntityFactory>(
                new ContainerControlledLifetimeManager());
            container.RegisterType<ISecurityRepository, EFSecurityRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IUserSecurity, WebUserSecurity>();
            container.RegisterType<IAuthenticationService, AuthenticationService>();
            container.RegisterType<ISecurityService, SecurityService>();
            container.RegisterType<IOAuthWebSecurity, OAuthWebSecurityWrapper>();

            #endregion

            #region Store

            container.RegisterType<IStoreEntityFactory, StoreEntityFactory>(new ContainerControlledLifetimeManager());

            container.RegisterType<IStoreService, StoreService>();
            container.RegisterType<IStoreRepository, EFStoreRepository>(new PerRequestLifetimeManager());

            #endregion

            #region Reporting

            container.RegisterType<IReportingService, ReportingService>();
            #endregion

            #endregion

            #region MVC Helpers

            //container.RegisterType<MarketingHelper>();
            container.RegisterType<PriceListClient>();
            container.RegisterType<StoreClient>();
            container.RegisterType<CatalogClient>();
            container.RegisterType<UserClient>();
            container.RegisterType<ShippingClient>();
            container.RegisterType<PromotionClient>();
            container.RegisterType<DynamicContentClient>();
            container.RegisterType<CountryClient>();
            container.RegisterType<OrderClient>();
            container.RegisterType<DisplayTemplateClient>();
            container.RegisterType<SettingsClient>();
            container.RegisterType<SequencesClient>();
            container.RegisterType<SeoKeywordClient>(new PerRequestLifetimeManager());
            container.RegisterType<ReviewClient>();
            //container.RegisterType<IPaymentOption, CreditCardOption>("creditcard");

            #endregion

            #region DynamicContent

            container.RegisterType<IDynamicContentService, DynamicContentService>();
            container.RegisterType<IDynamicContentRepository, EFDynamicContentRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IDynamicContentEvaluator, DynamicContentEvaluator>();

            #endregion

            #region AppConfig

            container.RegisterType<IAppConfigRepository, EFAppConfigRepository>(new PerRequestLifetimeManager());
            container.RegisterType<IAppConfigEntityFactory, AppConfigEntityFactory>(new ContainerControlledLifetimeManager());

            #endregion

            #region DisplayTemplates

            container.RegisterType<IDisplayTemplatesService, DisplayTemplatesService>();
            container.RegisterType<IDisplayTemplateEvaluator, DisplayTemplateEvaluator>();

            #endregion

            #region Events

            // Register event listeners
            container.RegisterType<IEntityEventListener, OrderChangeEventListener>("order");
            container.RegisterType<IEntityEventListener, PublicReplyEventListener>("customer");
            container.RegisterType<IEntityEventListener, CaseChangeEventListener>("customer");
            container.RegisterType<IEntityEventContext, EntityEventContext>(new PerRequestLifetimeManager());

            #endregion

            #region Jobs

            container.RegisterType<GenerateSearchIndexWork>();
            container.RegisterType<ProcessOrderStatusWork>();
            container.RegisterType<ProcessSearchIndexWork>();

            #endregion

            #region OutputCache

            container.RegisterType<IKeyBuilder, KeyBuilder>(new PerRequestLifetimeManager());
            container.RegisterType<IKeyGenerator, KeyGenerator>(new PerRequestLifetimeManager());
            container.RegisterType<IDonutHoleFiller, DonutHoleFiller>(new PerRequestLifetimeManager());
            container.RegisterType<ICacheHeadersHelper, CacheHeadersHelper>(new PerRequestLifetimeManager());
            container.RegisterType<ICacheSettingsManager, CacheSettingsManager>(new PerRequestLifetimeManager());
            container.RegisterType<IReadWriteOutputCacheManager, OutputCacheManager>(new PerRequestLifetimeManager());
            container.RegisterInstance<IActionSettingsSerialiser>(new EncryptingActionSettingsSerialiser(new ActionSettingsSerialiser(), new Encryptor()));
            container.RegisterType<ICacheService, CacheService>();

            #endregion

            #region Globalization

            //For using database resources
            container.RegisterType<IElementRepository, DatabaseElementRepository>(new PerRequestLifetimeManager());
            //For using Local Resources
            //container.RegisterInstance<IElementRepository>(new CacheElementRepository(new XmlElementRepository()));

            #endregion

            container.RegisterInstance(container);
        }
		private static UnityContainer GetLocalContainer()
		{
			var container = new UnityContainer();
			container.RegisterInstance<IUnityContainer>(container);
			container.RegisterType<IKnownSerializationTypes, CatalogEntityFactory>("catalog", new ContainerControlledLifetimeManager());
			container.RegisterInstance<IConsumerFactory>(new DomainAssemblyScannerConsumerFactory(container));
			container.RegisterType<IKnownSerializationTypes, DomainAssemblyScannerConsumerFactory>("scaned", new ContainerControlledLifetimeManager(), new InjectionConstructor(container));
			container.RegisterType<IConsumerFactory, DomainAssemblyScannerConsumerFactory>();
			container.RegisterType<ISystemObserver, NullSystemObserver>();
			container.RegisterType<IEngineProcess, SingleThreadConsumingProcess>();
			container.RegisterType<IMessageSerializer, DataContractMessageSerializer>();
			container.RegisterType<IQueueWriter, InMemoryQueueWriter>();
			container.RegisterType<IQueueReader, InMemoryQueueReader>();
			container.RegisterType<IMessageSender, DefaultMessageSender>(new ContainerControlledLifetimeManager());
			container.RegisterType<ISearchService, SearchService>();
			container.RegisterType<ISearchProvider, ElasticSearchProvider>();
			container.RegisterType<ISearchQueryBuilder, ElasticSearchQueryBuilder>();
			container.RegisterType<ISearchIndexBuilder, CatalogItemIndexBuilder>("catalogitem");
			container.RegisterType<IOperationLogRepository, OperationLogContext>();
			container.RegisterType<ILogOperationFactory, LogOperationFactory>();
			container.RegisterType<IBuildSettingsRepository, EFSearchRepository>();
			container.RegisterType<ISearchEntityFactory, SearchEntityFactory>(new ContainerControlledLifetimeManager());
			container.RegisterType<ISearchIndexController, SearchIndexController>();
			container.RegisterType<ICacheRepository, HttpCacheRepository>();

			#region Marketing
			container.RegisterType<IMarketingRepository, EFMarketingRepository>();
			container.RegisterType<IMarketingEntityFactory, MarketingEntityFactory>();
			container.RegisterType<IPromotionUsageProvider, PromotionUsageProvider>();
			container.RegisterType<IPromotionEntryPopulate, PromotionEntryPopulate>();
			#endregion

			#region Catalog
			container.RegisterType<ICatalogEntityFactory, CatalogEntityFactory>(new ContainerControlledLifetimeManager());

			container.RegisterType<ICatalogRepository, EFCatalogRepository>();
			container.RegisterType<IPricelistRepository, EFCatalogRepository>();
			container.RegisterType<ICatalogService, CatalogService>();

			container.RegisterType<IPriceListAssignmentEvaluator, PriceListAssignmentEvaluator>();
			container.RegisterType<IPriceListAssignmentEvaluationContext, PriceListAssignmentEvaluationContext>();
			#endregion

			#region Customer
			container.RegisterType<ICustomerEntityFactory, CustomerEntityFactory>(new ContainerControlledLifetimeManager());
			container.RegisterType<ICustomerRepository, EFCustomerRepository>();
			container.RegisterType<ICustomerSessionService, CustomerSessionService>();
			#endregion

			#region Inventory
			container.RegisterType<IInventoryEntityFactory, InventoryEntityFactory>(new ContainerControlledLifetimeManager());
			container.RegisterType<IInventoryRepository, EFInventoryRepository>();
			#endregion

			#region Order
			container.RegisterType<IOrderEntityFactory, OrderEntityFactory>(new ContainerControlledLifetimeManager());

			var activityProvider = WorkflowConfiguration.Instance.DefaultActivityProvider;
			var workflowService = new WFWorkflowService(activityProvider);
			container.RegisterInstance<IWorkflowService>(workflowService);

			container.RegisterType<IOrderRepository, EFOrderRepository>();
			container.RegisterType<ITaxRepository, EFOrderRepository>();
			container.RegisterType<IShippingRepository, EFOrderRepository>();
			container.RegisterType<IPaymentMethodRepository, EFOrderRepository>();

			container.RegisterType<ICountryRepository, EFOrderRepository>();
			container.RegisterType<IOrderService, OrderService>();
			#endregion

			#region Store
			container.RegisterType<IStoreEntityFactory, StoreEntityFactory>(new ContainerControlledLifetimeManager());

			container.RegisterType<IStoreService, StoreService>();
			container.RegisterType<IStoreRepository, EFStoreRepository>();
			#endregion

			return container;
		}
Ejemplo n.º 4
0
        private static IUnityContainer BuildUnityContainer()
        {
            #region Common Settings for Web and Services
            // this section is common for both web application and services application and should be kept identical
            var container = new UnityContainer();

            container.RegisterType<IKnownSerializationTypes, CatalogEntityFactory>("catalog", new ContainerControlledLifetimeManager());
            //container.RegisterType<IKnowSerializationTypes, OrderEntityFactory>("order", new ContainerControlledLifetimeManager(), null);
            container.RegisterInstance<IConsumerFactory>(new DomainAssemblyScannerConsumerFactory(container));
            container.RegisterType<IKnownSerializationTypes, DomainAssemblyScannerConsumerFactory>("scaned", new ContainerControlledLifetimeManager(), new InjectionConstructor(container));
            container.RegisterType<IConsumerFactory, DomainAssemblyScannerConsumerFactory>();
            container.RegisterType<ISystemObserver, NullSystemObserver>();
            container.RegisterType<IEngineProcess, SingleThreadConsumingProcess>();
            container.RegisterType<IMessageSerializer, DataContractMessageSerializer>();
            container.RegisterType<IQueueWriter, AzureQueueWriter>();
            container.RegisterType<IQueueReader, AzureQueueReader>();
            container.RegisterType<IMessageSender, DefaultMessageSender>(new ContainerControlledLifetimeManager());
            container.RegisterType<ICurrencyService, CurrencyService>(new ContainerControlledLifetimeManager());

            //container.RegisterType<ICacheProvider, InMemCachingProvider>();
            container.RegisterType<ICacheRepository, HttpCacheRepository>();

            container.RegisterType<ILogOperationFactory, LogOperationFactory>();
            container.RegisterType<IOperationLogRepository, OperationLogContext>();

            #region Interceptors

            // register interceptors
            container.RegisterType<IInterceptor, AuditChangeInterceptor>("audit");
            //container.RegisterType<IInterceptor, LogInterceptor>("log");
            //container.RegisterType<IInterceptor, EntityEventInterceptor>("events");

            #endregion

            #region Marketing
            //Needed for RemoveExpiredPromotionReservations SystemJob
            container.RegisterType<IMarketingRepository, EFMarketingRepository>();
            container.RegisterType<IMarketingEntityFactory, MarketingEntityFactory>();
            //container.RegisterType<IPromotionUsageProvider, PromotionUsageProvider>();
            //container.RegisterType<IPromotionEntryPopulate, PromotionEntryPopulate>();
            //container.RegisterType<IDynamicContentRepository, EFDynamicContentRepository>();
            #endregion

            #region Search
            var connectionString = ConnectionHelper.GetConnectionString("SearchConnectionString");
            if (connectionString == null)
            {
                Logger.Error("connectionString is null");
            }

            var searchConnection = new SearchConnection(connectionString);
            container.RegisterInstance<ISearchConnection>(searchConnection);

            container.RegisterType<ISearchService, SearchService>(new HierarchicalLifetimeManager());
            container.RegisterType<ISearchIndexController, SearchIndexController>();
            container.RegisterType<IBuildSettingsRepository, EFSearchRepository>();
            container.RegisterType<ISearchEntityFactory, SearchEntityFactory>(new ContainerControlledLifetimeManager());
            container.RegisterType<ISearchIndexBuilder, CatalogItemIndexBuilder>("catalogitem");

            // If provider specified as lucene, use lucene libraries, otherwise use default, which is elastic search
            if (string.Equals(searchConnection.Provider, SearchProviders.Lucene.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                // Lucene Search implementation
                container.RegisterType<ISearchProvider, LuceneSearchProvider>();
                container.RegisterType<ISearchQueryBuilder, LuceneSearchQueryBuilder>();
            }
            else
            {
                container.RegisterType<ISearchProvider, ElasticSearchProvider>();
                container.RegisterType<ISearchQueryBuilder, ElasticSearchQueryBuilder>();
            }

            #endregion

            #region AppConfig
            container.RegisterType<IAppConfigEntityFactory, AppConfigEntityFactory>();
            container.RegisterType<IAppConfigRepository, EFAppConfigRepository>();
            #endregion

            #region Assets
            container.RegisterType<IAssetEntityFactory, AssetEntityFactory>();
            container.RegisterType<IAssetRepository, AzureBlobAssetRepository>();
            container.RegisterType<IBlobStorageProvider, AzureBlobAssetRepository>();
            container.RegisterType<IAssetService, AssetService>();
            #endregion

            #region Catalog
            container.RegisterType<ICatalogEntityFactory, CatalogEntityFactory>(new ContainerControlledLifetimeManager());

            container.RegisterType<ICatalogRepository, EFCatalogRepository>();
            container.RegisterType<ICatalogOutlineBuilder, CatalogOutlineBuilder>();
            container.RegisterType<IPricelistRepository, EFCatalogRepository>();
            container.RegisterType<ICatalogService, CatalogService>();
            container.RegisterType<IPriceListAssignmentEvaluator, PriceListAssignmentEvaluator>();
            container.RegisterType<IPriceListAssignmentEvaluationContext, PriceListAssignmentEvaluationContext>();

            container.RegisterType<IImportJobEntityFactory, ImportJobEntityFactory>(
                new ContainerControlledLifetimeManager());
            container.RegisterType<IImportRepository, EFImportingRepository>();
            container.RegisterType<IImportService, ImportService>();
            #endregion

            //#region Customer
            //container.RegisterType<ICustomerEntityFactory, CustomerEntityFactory>(new ContainerControlledLifetimeManager());

            //container.RegisterType<ICustomerRepository, EFCustomerRepository>();
            //#endregion

            //#region Inventory
            //container.RegisterType<IInventoryEntityFactory, InventoryEntityFactory>(new ContainerControlledLifetimeManager());
            //#endregion

            #region Order
            container.RegisterType<IOrderEntityFactory, OrderEntityFactory>(new ContainerControlledLifetimeManager());

            var activityProvider = WorkflowConfiguration.Instance.DefaultActivityProvider;
            var workflowService = new WFWorkflowService(activityProvider);
            container.RegisterInstance<IWorkflowService>(workflowService);
            container.RegisterType<IOrderStateController, OrderStateController>();

            container.RegisterType<IOrderRepository, EFOrderRepository>();
            container.RegisterType<IShippingRepository, EFOrderRepository>();
            container.RegisterType<IPaymentMethodRepository, EFOrderRepository>();
            container.RegisterType<ITaxRepository, EFOrderRepository>();

            container.RegisterType<ICountryRepository, EFOrderRepository>();
            container.RegisterType<IOrderService, OrderService>();
            #endregion

            #region Customer
            container.RegisterType<ICustomerEntityFactory, CustomerEntityFactory>(
     new ContainerControlledLifetimeManager());

            container.RegisterType<ICustomerRepository, EFCustomerRepository>();
            container.RegisterType<ICustomerSessionService, CustomerSessionService>();
            #endregion

            #region Review
            container.RegisterType<IReviewEntityFactory, ReviewEntityFactory>(new ContainerControlledLifetimeManager());
            container.RegisterType<IReviewRepository, EFReviewRepository>();
            #endregion

            #region Security
            container.RegisterType<ISecurityEntityFactory, SecurityEntityFactory>(new ContainerControlledLifetimeManager());

            //container.RegisterType<ISecurityService, SecurityService>();
            container.RegisterType<ISecurityRepository, EFSecurityRepository>();
            #endregion


            #region Store
            container.RegisterType<IStoreEntityFactory, StoreEntityFactory>(new ContainerControlledLifetimeManager());

            container.RegisterType<IStoreService, StoreService>();
            container.RegisterType<IStoreRepository, EFStoreRepository>();
            #endregion
            #endregion

            container.RegisterType<GenerateSearchIndexWork>();
            container.RegisterType<ProcessOrderStatusWork>();
            container.RegisterType<ProcessSearchIndexWork>();

            return container;
        }