/// <summary> /// Register dependencies /// </summary> /// <param name="config">Config</param> protected virtual void RegisterDependencies(YStoryConfig config) { var builder = new ContainerBuilder(); //dependencies var typeFinder = new WebAppTypeFinder(); builder.RegisterInstance(config).As <YStoryConfig>().SingleInstance(); builder.RegisterInstance(this).As <IEngine>().SingleInstance(); builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); //register dependencies provided by other assemblies var drTypes = typeFinder.FindClassesOfType <IDependencyRegistrar>(); var drInstances = new List <IDependencyRegistrar>(); foreach (var drType in drTypes) { drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType)); } //sort drInstances = drInstances.AsQueryable().OrderBy(t => t.Subscription).ToList(); foreach (var dependencyRegistrar in drInstances) { dependencyRegistrar.Register(builder, typeFinder, config); } var container = builder.Build(); this._containerManager = new ContainerManager(container); //set dependency resolver DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }
/// <summary> /// Register mapping /// </summary> /// <param name="config">Config</param> protected virtual void RegisterMapperConfiguration(YStoryConfig config) { //dependencies var typeFinder = new WebAppTypeFinder(); //register mapper configurations provided by other assemblies var mcTypes = typeFinder.FindClassesOfType <IMapperConfiguration>(); var mcInstances = new List <IMapperConfiguration>(); foreach (var mcType in mcTypes) { mcInstances.Add((IMapperConfiguration)Activator.CreateInstance(mcType)); } //sort mcInstances = mcInstances.AsQueryable().OrderBy(t => t.Subscription).ToList(); //get configurations var configurationActions = new List <Action <IMapperConfigurationExpression> >(); foreach (var mc in mcInstances) { configurationActions.Add(mc.GetConfiguration()); } //register AutoMapperConfiguration.Init(configurationActions); }
public AzurePictureService(IRepository <Picture> pictureRepository, IRepository <ArticlePicture> articlePictureRepository, ISettingService settingService, IWebHelper webHelper, ILogger logger, IDbContext dbContext, IEventPublisher eventPublisher, MediaSettings mediaSettings, YStoryConfig config, IDataProvider dataProvider) : base(pictureRepository, articlePictureRepository, settingService, webHelper, logger, dbContext, eventPublisher, mediaSettings, dataProvider) { this._mediaSettings = mediaSettings; this._config = config; if (String.IsNullOrEmpty(_config.AzureBlobStorageConnectionString)) { throw new Exception("Azure connection string for BLOB is not specified"); } if (String.IsNullOrEmpty(_config.AzureBlobStorageContainerName)) { throw new Exception("Azure container name for BLOB is not specified"); } if (String.IsNullOrEmpty(_config.AzureBlobStorageEndPoint)) { throw new Exception("Azure end point for BLOB is not specified"); } _storageAccount = CloudStorageAccount.Parse(_config.AzureBlobStorageConnectionString); if (_storageAccount == null) { throw new Exception("Azure connection string for BLOB is not wrong"); } //should we do it for each HTTP request? blobClient = _storageAccount.CreateCloudBlobClient(); BlobContainerPermissions containerPermissions = new BlobContainerPermissions(); containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob; //container.SetPermissions(containerPermissions); container_thumb = blobClient.GetContainerReference(_config.AzureBlobStorageContainerName); container_thumb.CreateIfNotExists(); container_thumb.SetPermissions(containerPermissions); }
public RedisCacheManager(YStoryConfig config, IRedisConnectionWrapper connectionWrapper) { if (String.IsNullOrEmpty(config.RedisCachingConnectionString)) { throw new Exception("Redis connection string is empty"); } // ConnectionMultiplexer.Connect should only be called once and shared between callers this._connectionWrapper = connectionWrapper; this._db = _connectionWrapper.GetDatabase(); this._perRequestCacheManager = EngineContext.Current.Resolve <ICacheManager>(); }
/// <summary> /// Initialize components and plugins in the nop environment. /// </summary> /// <param name="config">Config</param> public void Initialize(YStoryConfig config) { //register dependencies RegisterDependencies(config); //register mapper configurations RegisterMapperConfiguration(config); //startup tasks if (!config.IgnoreStartupTasks) { RunStartupTasks(); } }
/// <summary> /// Register services and interfaces /// </summary> /// <param name="builder">Container builder</param> /// <param name="typeFinder">Type finder</param> /// <param name="config">Config</param> public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, YStoryConfig config) { //we cache presentation models between requests builder.RegisterType <CategoryController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <CustomerController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <CustomerRoleController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <HomeController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <PublisherController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <SubscriptionController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <ArticleController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); }
/// <summary> /// Ctor /// </summary> /// <param name="config">Config</param> /// <param name="httpContext">HTTP context</param> public UserAgentHelper(YStoryConfig config, HttpContextBase httpContext) { this._config = config; this._httpContext = httpContext; }
/// <summary> /// Register services and interfaces /// </summary> /// <param name="builder">Container builder</param> /// <param name="typeFinder">Type finder</param> /// <param name="config">Config</param> public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, YStoryConfig config) { //installation localization service builder.RegisterType <InstallationLocalizationService>().As <IInstallationLocalizationService>().InstancePerLifetimeScope(); //controllers (we cache some data between HTTP requests) builder.RegisterType <ArticleController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); builder.RegisterType <ShoppingCartController>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")); //factories (we cache presentation models between HTTP requests) builder.RegisterType <AddressModelFactory>().As <IAddressModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <BlogModelFactory>().As <IBlogModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <CatalogModelFactory>().As <ICatalogModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <CheckoutModelFactory>().As <ICheckoutModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <CommonModelFactory>().As <ICommonModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <CountryModelFactory>().As <ICountryModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <CustomerModelFactory>().As <ICustomerModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <ForumModelFactory>().As <IForumModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <ExternalAuthenticationModelFactory>().As <IExternalAuthenticationModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <NewsModelFactory>().As <INewsModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <NewsletterModelFactory>().As <INewsletterModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <SubscriptionModelFactory>().As <ISubscriptionModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <PollModelFactory>().As <IPollModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <PrivateMessagesModelFactory>().As <IPrivateMessagesModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <ArticleModelFactory>().As <IArticleModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <ProfileModelFactory>().As <IProfileModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <ReturnRequestModelFactory>().As <IReturnRequestModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <ShoppingCartModelFactory>().As <IShoppingCartModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <TopicModelFactory>().As <ITopicModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <ContributorModelFactory>().As <IContributorModelFactory>() .InstancePerLifetimeScope(); builder.RegisterType <WidgetModelFactory>().As <IWidgetModelFactory>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); }
public RedisConnectionWrapper(YStoryConfig config) { this._config = config; this._connectionString = new Lazy <string>(GetConnectionString); this._redisLockFactory = CreateRedisLockFactory(); }
/// <summary> /// Register services and interfaces /// </summary> /// <param name="builder">Container builder</param> /// <param name="typeFinder">Type finder</param> /// <param name="config">Config</param> public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, YStoryConfig config) { //HTTP context and other related stuff builder.Register(c => //register FakeHttpContext when HttpContext is not available HttpContext.Current != null ? (new HttpContextWrapper(HttpContext.Current) as HttpContextBase) : (new FakeHttpContext("~/") as HttpContextBase)) .As <HttpContextBase>() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve <HttpContextBase>().Request) .As <HttpRequestBase>() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve <HttpContextBase>().Response) .As <HttpResponseBase>() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve <HttpContextBase>().Server) .As <HttpServerUtilityBase>() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve <HttpContextBase>().Session) .As <HttpSessionStateBase>() .InstancePerLifetimeScope(); //web helper builder.RegisterType <WebHelper>().As <IWebHelper>().InstancePerLifetimeScope(); //user agent helper builder.RegisterType <UserAgentHelper>().As <IUserAgentHelper>().InstancePerLifetimeScope(); //controllers builder.RegisterControllers(typeFinder.GetAssemblies().ToArray()); //data layer var dataSettingsManager = new DataSettingsManager(); var dataProviderSettings = dataSettingsManager.LoadSettings(); builder.Register(c => dataSettingsManager.LoadSettings()).As <DataSettings>(); builder.Register(x => new EfDataProviderManager(x.Resolve <DataSettings>())).As <BaseDataProviderManager>().InstancePerDependency(); builder.Register(x => x.Resolve <BaseDataProviderManager>().LoadDataProvider()).As <IDataProvider>().InstancePerDependency(); if (dataProviderSettings != null && dataProviderSettings.IsValid()) { var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings()); var dataProvider = efDataProviderManager.LoadDataProvider(); dataProvider.InitConnectionFactory(); builder.Register <IDbContext>(c => new YStoryObjectContext(dataProviderSettings.DataConnectionString)).InstancePerLifetimeScope(); } else { builder.Register <IDbContext>(c => new YStoryObjectContext(dataSettingsManager.LoadSettings().DataConnectionString)).InstancePerLifetimeScope(); } builder.RegisterGeneric(typeof(EfRepository <>)).As(typeof(IRepository <>)).InstancePerLifetimeScope(); //plugins builder.RegisterType <PluginFinder>().As <IPluginFinder>().InstancePerLifetimeScope(); builder.RegisterType <OfficialFeedManager>().As <IOfficialFeedManager>().InstancePerLifetimeScope(); //cache managers if (config.RedisCachingEnabled) { builder.RegisterType <RedisConnectionWrapper>().As <IRedisConnectionWrapper>().SingleInstance(); builder.RegisterType <RedisCacheManager>().As <ICacheManager>().Named <ICacheManager>("nop_cache_static").InstancePerLifetimeScope(); } else { builder.RegisterType <MemoryCacheManager>().As <ICacheManager>().Named <ICacheManager>("nop_cache_static").SingleInstance(); } builder.RegisterType <PerRequestCacheManager>().As <ICacheManager>().Named <ICacheManager>("nop_cache_per_request").InstancePerLifetimeScope(); if (config.RunOnAzureWebApps) { builder.RegisterType <AzureWebAppsMachineNameProvider>().As <IMachineNameProvider>().SingleInstance(); } else { builder.RegisterType <DefaultMachineNameProvider>().As <IMachineNameProvider>().SingleInstance(); } //work context builder.RegisterType <WebWorkContext>().As <IWorkContext>().InstancePerLifetimeScope(); //store context builder.RegisterType <WebStoreContext>().As <IStoreContext>().InstancePerLifetimeScope(); //services builder.RegisterType <CategoryService>().As <ICategoryService>().InstancePerLifetimeScope(); builder.RegisterType <CompareArticlesService>().As <ICompareArticlesService>().InstancePerLifetimeScope(); builder.RegisterType <RecentlyViewedArticlesService>().As <IRecentlyViewedArticlesService>().InstancePerLifetimeScope(); builder.RegisterType <PublisherService>().As <IPublisherService>().InstancePerLifetimeScope(); builder.RegisterType <PriceFormatter>().As <IPriceFormatter>().InstancePerLifetimeScope(); builder.RegisterType <ArticleAttributeFormatter>().As <IArticleAttributeFormatter>().InstancePerLifetimeScope(); builder.RegisterType <ArticleAttributeParser>().As <IArticleAttributeParser>().InstancePerLifetimeScope(); builder.RegisterType <ArticleAttributeService>().As <IArticleAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <ArticleService>().As <IArticleService>().InstancePerLifetimeScope(); builder.RegisterType <CopyArticleService>().As <ICopyArticleService>().InstancePerLifetimeScope(); builder.RegisterType <SpecificationAttributeService>().As <ISpecificationAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <ArticleTemplateService>().As <IArticleTemplateService>().InstancePerLifetimeScope(); builder.RegisterType <CategoryTemplateService>().As <ICategoryTemplateService>().InstancePerLifetimeScope(); builder.RegisterType <PublisherTemplateService>().As <IPublisherTemplateService>().InstancePerLifetimeScope(); builder.RegisterType <TopicTemplateService>().As <ITopicTemplateService>().InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <ArticleTagService>().As <IArticleTagService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <AddressAttributeFormatter>().As <IAddressAttributeFormatter>().InstancePerLifetimeScope(); builder.RegisterType <AddressAttributeParser>().As <IAddressAttributeParser>().InstancePerLifetimeScope(); builder.RegisterType <AddressAttributeService>().As <IAddressAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <AddressService>().As <IAddressService>().InstancePerLifetimeScope(); builder.RegisterType <AffiliateService>().As <IAffiliateService>().InstancePerLifetimeScope(); builder.RegisterType <ContributorService>().As <IContributorService>().InstancePerLifetimeScope(); builder.RegisterType <SearchTermService>().As <ISearchTermService>().InstancePerLifetimeScope(); builder.RegisterType <GenericAttributeService>().As <IGenericAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <FulltextService>().As <IFulltextService>().InstancePerLifetimeScope(); builder.RegisterType <MaintenanceService>().As <IMaintenanceService>().InstancePerLifetimeScope(); builder.RegisterType <CustomerAttributeFormatter>().As <ICustomerAttributeFormatter>().InstancePerLifetimeScope(); builder.RegisterType <CustomerAttributeParser>().As <ICustomerAttributeParser>().InstancePerLifetimeScope(); builder.RegisterType <CustomerAttributeService>().As <ICustomerAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <CustomerService>().As <ICustomerService>().InstancePerLifetimeScope(); builder.RegisterType <CustomerRegistrationService>().As <ICustomerRegistrationService>().InstancePerLifetimeScope(); builder.RegisterType <CustomerReportService>().As <ICustomerReportService>().InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <PermissionService>().As <IPermissionService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <AclService>().As <IAclService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <PriceCalculationService>().As <IPriceCalculationService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <GeoLookupService>().As <IGeoLookupService>().InstancePerLifetimeScope(); builder.RegisterType <CountryService>().As <ICountryService>().InstancePerLifetimeScope(); builder.RegisterType <CurrencyService>().As <ICurrencyService>().InstancePerLifetimeScope(); builder.RegisterType <MeasureService>().As <IMeasureService>().InstancePerLifetimeScope(); builder.RegisterType <StateProvinceService>().As <IStateProvinceService>().InstancePerLifetimeScope(); builder.RegisterType <StoreService>().As <IStoreService>().InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <StoreMappingService>().As <IStoreMappingService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <SettingService>().As <ISettingService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterSource(new SettingsSource()); //use static cache (between HTTP requests) builder.RegisterType <LocalizationService>().As <ILocalizationService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <LocalizedEntityService>().As <ILocalizedEntityService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <LanguageService>().As <ILanguageService>().InstancePerLifetimeScope(); builder.RegisterType <DownloadService>().As <IDownloadService>().InstancePerLifetimeScope(); //picture service var useAzureBlobStorage = !String.IsNullOrEmpty(config.AzureBlobStorageConnectionString); if (useAzureBlobStorage) { //Windows Azure BLOB builder.RegisterType <AzurePictureService>().As <IPictureService>().InstancePerLifetimeScope(); } else { //standard file system builder.RegisterType <PictureService>().As <IPictureService>().InstancePerLifetimeScope(); } builder.RegisterType <MessageTemplateService>().As <IMessageTemplateService>().InstancePerLifetimeScope(); builder.RegisterType <QueuedEmailService>().As <IQueuedEmailService>().InstancePerLifetimeScope(); builder.RegisterType <NewsLetterSubscriptionService>().As <INewsLetterSubscriptionService>().InstancePerLifetimeScope(); builder.RegisterType <CampaignService>().As <ICampaignService>().InstancePerLifetimeScope(); builder.RegisterType <EmailAccountService>().As <IEmailAccountService>().InstancePerLifetimeScope(); builder.RegisterType <WorkflowMessageService>().As <IWorkflowMessageService>().InstancePerLifetimeScope(); builder.RegisterType <MessageTokenProvider>().As <IMessageTokenProvider>().InstancePerLifetimeScope(); builder.RegisterType <Tokenizer>().As <ITokenizer>().InstancePerLifetimeScope(); builder.RegisterType <EmailSender>().As <IEmailSender>().InstancePerLifetimeScope(); builder.RegisterType <CheckoutAttributeFormatter>().As <ICheckoutAttributeFormatter>().InstancePerLifetimeScope(); builder.RegisterType <CheckoutAttributeParser>().As <ICheckoutAttributeParser>().InstancePerLifetimeScope(); builder.RegisterType <CheckoutAttributeService>().As <ICheckoutAttributeService>().InstancePerLifetimeScope(); builder.RegisterType <SubscriptionService1>().As <ISubscriptionService1>().InstancePerLifetimeScope(); builder.RegisterType <SubscriptionReportService>().As <ISubscriptionReportService>().InstancePerLifetimeScope(); builder.RegisterType <SubscriptionProcessingService>().As <ISubscriptionProcessingService>().InstancePerLifetimeScope(); builder.RegisterType <SubscriptionTotalCalculationService>().As <ISubscriptionTotalCalculationService>().InstancePerLifetimeScope(); builder.RegisterType <ReturnRequestService>().As <IReturnRequestService>().InstancePerLifetimeScope(); builder.RegisterType <RewardPointService>().As <IRewardPointService>().InstancePerLifetimeScope(); builder.RegisterType <ShoppingCartService>().As <IShoppingCartService>().InstancePerLifetimeScope(); builder.RegisterType <CustomNumberFormatter>().As <ICustomNumberFormatter>().InstancePerLifetimeScope(); builder.RegisterType <PaymentService>().As <IPaymentService>().InstancePerLifetimeScope(); builder.RegisterType <EncryptionService>().As <IEncryptionService>().InstancePerLifetimeScope(); builder.RegisterType <FormsAuthenticationService>().As <IAuthenticationService>().InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <UrlRecordService>().As <IUrlRecordService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); builder.RegisterType <TaxCategoryService>().As <ITaxCategoryService>().InstancePerLifetimeScope(); builder.RegisterType <TaxService>().As <ITaxService>().InstancePerLifetimeScope(); builder.RegisterType <DefaultLogger>().As <ILogger>().InstancePerLifetimeScope(); //use static cache (between HTTP requests) builder.RegisterType <CustomerActivityService>().As <ICustomerActivityService>() .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static")) .InstancePerLifetimeScope(); bool databaseInstalled = DataSettingsHelper.DatabaseIsInstalled(); if (!databaseInstalled) { //installation service if (config.UseFastInstallationService) { builder.RegisterType <SqlFileInstallationService>().As <IInstallationService>().InstancePerLifetimeScope(); } else { builder.RegisterType <CodeFirstInstallationService>().As <IInstallationService>().InstancePerLifetimeScope(); } } builder.RegisterType <ForumService>().As <IForumService>().InstancePerLifetimeScope(); builder.RegisterType <PollService>().As <IPollService>().InstancePerLifetimeScope(); builder.RegisterType <BlogService>().As <IBlogService>().InstancePerLifetimeScope(); builder.RegisterType <WidgetService>().As <IWidgetService>().InstancePerLifetimeScope(); builder.RegisterType <TopicService>().As <ITopicService>().InstancePerLifetimeScope(); builder.RegisterType <NewsService>().As <INewsService>().InstancePerLifetimeScope(); builder.RegisterType <DateTimeHelper>().As <IDateTimeHelper>().InstancePerLifetimeScope(); builder.RegisterType <SitemapGenerator>().As <ISitemapGenerator>().InstancePerLifetimeScope(); builder.RegisterType <PageHeadBuilder>().As <IPageHeadBuilder>().InstancePerLifetimeScope(); builder.RegisterType <ScheduleTaskService>().As <IScheduleTaskService>().InstancePerLifetimeScope(); builder.RegisterType <ExportManager>().As <IExportManager>().InstancePerLifetimeScope(); builder.RegisterType <ImportManager>().As <IImportManager>().InstancePerLifetimeScope(); builder.RegisterType <PdfService>().As <IPdfService>().InstancePerLifetimeScope(); builder.RegisterType <ThemeProvider>().As <IThemeProvider>().InstancePerLifetimeScope(); builder.RegisterType <ThemeContext>().As <IThemeContext>().InstancePerLifetimeScope(); builder.RegisterType <ExternalAuthorizer>().As <IExternalAuthorizer>().InstancePerLifetimeScope(); builder.RegisterType <OpenAuthenticationService>().As <IOpenAuthenticationService>().InstancePerLifetimeScope(); builder.RegisterType <RoutePublisher>().As <IRoutePublisher>().SingleInstance(); //Register event consumers var consumers = typeFinder.FindClassesOfType(typeof(IConsumer <>)).ToList(); foreach (var consumer in consumers) { builder.RegisterType(consumer) .As(consumer.FindInterfaces((type, criteria) => { var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition()); return(isMatch); }, typeof(IConsumer <>))) .InstancePerLifetimeScope(); } builder.RegisterType <EventPublisher>().As <IEventPublisher>().SingleInstance(); builder.RegisterType <SubscriptionService>().As <ISubscriptionService>().SingleInstance(); }
public InstallController(IInstallationLocalizationService locService, YStoryConfig config) { this._locService = locService; this._config = config; }