private void ConfigureGeneralServices(SiteStructureOptions options) { if (options.SiteId == 0) { throw new Exception("SiteId is not configured."); } //настройки Services.AddSingleton(new QpSiteStructureBuildSettings { IsStage = options.IsStage, SiteId = options.SiteId, LoadAbstractItemFieldsToDetailsCollection = options.LoadAbstractItemFieldsToDetailsCollection, RootPageDiscriminator = options.RootPageDiscriminator, UploadUrlPlaceholder = options.UploadUrlPlaceholder, CacheFetchTimeoutAbstractItemStorage = options.CacheFetchTimeoutAbstractItemStorage }); Services.AddSingleton(new QpSiteStructureCacheSettings { SiteStructureCachePeriod = options.SiteStructureCachePeriod, QpSchemeCachePeriod = options.QpSchemeCachePeriod, ItemDefinitionCachePeriod = options.ItemDefinitionCachePeriod }); //DAL if (!Services.Any(x => x.ServiceType == typeof(IUnitOfWork))) { if (String.IsNullOrWhiteSpace(options.QpConnectionString)) { throw new Exception("QpConnectionString is not configured."); } if (String.IsNullOrWhiteSpace(options.QpDatabaseType)) { throw new Exception("QpDatabaseType is not configured."); } Services.AddScoped <IUnitOfWork, UnitOfWork>(sp => { return(new UnitOfWork(options.QpConnectionString, options.QpDatabaseType)); }); } Services.TryAddScoped <IMetaInfoRepository, MetaInfoRepository>(); Services.TryAddScoped <INetNameQueryAnalyzer, NetNameQueryAnalyzer>(); Services.TryAddScoped <IAbstractItemRepository, AbstractItemRepository>(); Services.TryAddScoped <IItemDefinitionRepository, ItemDefinitionRepository>(); Services.TryAddScoped <IQpUrlResolver, QpUrlResolver>(); Services.TryAddScoped <IAbstractItemStorageBuilder, QpAbstractItemStorageBuilder>(); Services.TryAddScoped <IAbstractItemStorageProvider, SimpleAbstractItemStorageProvider>(); Services.TryAddSingleton <ICacheProvider, VersionedCacheCoreProvider>(); Services.TryAddSingleton <IQpContentCacheTagNamingProvider, NullQpContentCacheTagNamingProvider>(); Services.TryAddSingleton <ITargetingFilterAccessor, NullTargetingFilterAccessor>(); Services.TryAddSingleton <IItemFinder, ItemFinder>(); }
/// <summary> /// Конфигурация сервисов для построения структуры сайта /// </summary> /// <param name="services"></param> /// <param name="setupAction"></param> public SiteStructureEngineConfigurator(IServiceCollection services, Action <SiteStructureOptions> setupAction) { Services = services; var options = new SiteStructureOptions(); setupAction?.Invoke(options); ConfigureGeneralServices(options); Services.TryAddScoped <IAbstractItemFactory, UniversalAbstractItemFactory>(); }