/// <summary> /// Adds core Umbraco services /// </summary> /// <remarks> /// This will not add any composers/components /// </remarks> public static IUmbracoBuilder AddUmbracoCore(this IUmbracoBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } // Add ASP.NET specific services builder.Services.AddUnique <IBackOfficeInfo, AspNetCoreBackOfficeInfo>(); builder.Services.AddUnique <IHostingEnvironment, AspNetCoreHostingEnvironment>(); builder.Services.AddHostedService(factory => factory.GetRequiredService <IRuntime>()); // Add supported databases builder.AddUmbracoSqlServerSupport(); builder.AddUmbracoSqlCeSupport(); builder.Services.AddSingleton <DatabaseSchemaCreatorFactory>(); // Must be added here because DbProviderFactories is netstandard 2.1 so cannot exist in Infra for now builder.Services.AddSingleton <IDbProviderFactoryCreator>(factory => new DbProviderFactoryCreator( DbProviderFactories.GetFactory, factory.GetServices <ISqlSyntaxProvider>(), factory.GetServices <IBulkSqlInsertProvider>(), factory.GetServices <IDatabaseCreator>(), factory.GetServices <IProviderSpecificMapperFactory>() )); builder.AddCoreInitialServices(); builder.AddTelemetryProviders(); // aspnet app lifetime mgmt builder.Services.AddUnique <IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>(); builder.Services.AddUnique <IApplicationShutdownRegistry, AspNetCoreApplicationShutdownRegistry>(); return(builder); }
/// <summary> /// Adds core Umbraco services /// </summary> /// <remarks> /// This will not add any composers/components /// </remarks> public static IUmbracoBuilder AddUmbracoCore(this IUmbracoBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } // Add ASP.NET specific services builder.Services.AddUnique <IBackOfficeInfo, AspNetCoreBackOfficeInfo>(); builder.Services.AddUnique <IHostingEnvironment>(sp => ActivatorUtilities.CreateInstance <AspNetCoreHostingEnvironment>( sp, sp.GetRequiredService <IApplicationDiscriminator>())); builder.Services.AddHostedService(factory => factory.GetRequiredService <IRuntime>()); builder.Services.AddSingleton <DatabaseSchemaCreatorFactory>(); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IDatabaseProviderMetadata, CustomConnectionStringDatabaseProviderMetadata>()); // Must be added here because DbProviderFactories is netstandard 2.1 so cannot exist in Infra for now builder.Services.AddSingleton <IDbProviderFactoryCreator>(factory => new DbProviderFactoryCreator( DbProviderFactories.GetFactory, factory.GetServices <ISqlSyntaxProvider>(), factory.GetServices <IBulkSqlInsertProvider>(), factory.GetServices <IDatabaseCreator>(), factory.GetServices <IProviderSpecificMapperFactory>(), factory.GetServices <IProviderSpecificInterceptor>())); builder.AddCoreInitialServices(); builder.AddTelemetryProviders(); // aspnet app lifetime mgmt builder.Services.AddUnique <IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>(); builder.Services.AddUnique <IApplicationShutdownRegistry, AspNetCoreApplicationShutdownRegistry>(); builder.Services.AddTransient <IIpAddressUtilities, IpAddressUtilities>(); return(builder); }