コード例 #1
0
        /// <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.AddUnique <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();

            // aspnet app lifetime mgmt
            builder.Services.AddUnique <IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>();
            builder.Services.AddUnique <IApplicationShutdownRegistry, AspNetCoreApplicationShutdownRegistry>();

            return(builder);
        }
コード例 #2
0
 /// <inheritdoc />
 public void Compose(IUmbracoBuilder builder)
 => builder.AddUmbracoSqlServerSupport();