/// <summary> /// Adds Umbraco composers for plugins /// </summary> public static IUmbracoBuilder AddComposers(this IUmbracoBuilder builder) { IEnumerable <Type> composerTypes = builder.TypeLoader.GetTypes <IComposer>(); IEnumerable <Attribute> enableDisable = builder.TypeLoader.GetAssemblyAttributes(typeof(EnableComposerAttribute), typeof(DisableComposerAttribute)); new ComposerGraph(builder, composerTypes, enableDisable, builder.BuilderLoggerFactory.CreateLogger <ComposerGraph>()).Compose(); return(builder); }
private static IUmbracoBuilder AddHttpClients(this IUmbracoBuilder builder) { builder.Services.AddHttpClient(); builder.Services.AddHttpClient(Constants.HttpClients.IgnoreCertificateErrors) .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }); return(builder); }
/// <summary> /// Adds Sql Server support for Umbraco /// </summary> private static IUmbracoBuilder AddUmbracoSqlServerSupport(this IUmbracoBuilder builder) { DbProviderFactories.RegisterFactory(Cms.Core.Constants.DbProviderNames.SqlServer, SqlClientFactory.Instance); builder.Services.AddSingleton <ISqlSyntaxProvider, SqlServerSyntaxProvider>(); builder.Services.AddSingleton <IBulkSqlInsertProvider, SqlServerBulkSqlInsertProvider>(); builder.Services.AddSingleton <IDatabaseCreator, SqlServerDatabaseCreator>(); return(builder); }
/// <summary> /// Adds umbraco's embedded model builder support /// </summary> public static IUmbracoBuilder AddModelsBuilder(this IUmbracoBuilder builder) { var umbServices = new UniqueServiceDescriptor(typeof(UmbracoServices), typeof(UmbracoServices), ServiceLifetime.Singleton); if (builder.Services.Contains(umbServices)) { // if this ext method is called more than once just exit return(builder); } builder.Services.Add(umbServices); builder.AddInMemoryModelsRazorEngine(); // TODO: I feel like we could just do builder.AddNotificationHandler<ModelsBuilderNotificationHandler>() and it // would automatically just register for all implemented INotificationHandler{T}? builder.AddNotificationHandler <TemplateSavingNotification, ModelsBuilderNotificationHandler>(); builder.AddNotificationHandler <ServerVariablesParsingNotification, ModelsBuilderNotificationHandler>(); builder.AddNotificationHandler <ModelBindingErrorNotification, ModelsBuilderNotificationHandler>(); builder.AddNotificationHandler <UmbracoApplicationStartingNotification, AutoModelsNotificationHandler>(); builder.AddNotificationHandler <UmbracoRequestEndNotification, AutoModelsNotificationHandler>(); builder.AddNotificationHandler <ContentTypeCacheRefresherNotification, AutoModelsNotificationHandler>(); builder.AddNotificationHandler <DataTypeCacheRefresherNotification, AutoModelsNotificationHandler>(); builder.Services.AddSingleton <ModelsGenerator>(); builder.Services.AddSingleton <OutOfDateModelsStatus>(); builder.AddNotificationHandler <ContentTypeCacheRefresherNotification, OutOfDateModelsStatus>(); builder.AddNotificationHandler <DataTypeCacheRefresherNotification, OutOfDateModelsStatus>(); builder.Services.AddSingleton <ModelsGenerationError>(); builder.Services.AddSingleton <InMemoryModelFactory>(); // This is what the community MB would replace, all of the above services are fine to be registered // even if the community MB is in place. builder.Services.AddSingleton <IPublishedModelFactory>(factory => { ModelsBuilderSettings config = factory.GetRequiredService <IOptions <ModelsBuilderSettings> >().Value; if (config.ModelsMode == ModelsMode.InMemoryAuto) { return(factory.GetRequiredService <InMemoryModelFactory>()); } else { return(factory.CreateDefaultPublishedModelFactory()); } }); if (!builder.Services.Any(x => x.ServiceType == typeof(IModelsBuilderDashboardProvider))) { builder.Services.AddUnique <IModelsBuilderDashboardProvider, NoopModelsBuilderDashboardProvider>(); } return(builder); }
/// <summary> /// Adds the Umbraco repositories /// </summary> internal static IUmbracoBuilder AddRepositories(this IUmbracoBuilder builder) { // repositories builder.Services.AddUnique <IAuditRepository, AuditRepository>(); builder.Services.AddUnique <IAuditEntryRepository, AuditEntryRepository>(); builder.Services.AddUnique <ICacheInstructionRepository, CacheInstructionRepository>(); builder.Services.AddUnique <IContentTypeRepository, ContentTypeRepository>(); builder.Services.AddUnique <IDataTypeContainerRepository, DataTypeContainerRepository>(); builder.Services.AddUnique <IDataTypeRepository, DataTypeRepository>(); builder.Services.AddUnique <IDictionaryRepository, DictionaryRepository>(); builder.Services.AddUnique <IDocumentBlueprintRepository, DocumentBlueprintRepository>(); builder.Services.AddUnique <IDocumentRepository, DocumentRepository>(); builder.Services.AddUnique <IDocumentVersionRepository, DocumentVersionRepository>(); builder.Services.AddUnique <IDocumentTypeContainerRepository, DocumentTypeContainerRepository>(); builder.Services.AddUnique <IDomainRepository, DomainRepository>(); builder.Services.AddMultipleUnique <IEntityRepository, IEntityRepositoryExtended, EntityRepository>(); builder.Services.AddUnique <ITwoFactorLoginRepository, TwoFactorLoginRepository>(); builder.Services.AddUnique <ExternalLoginRepository>(); builder.Services.AddUnique <IExternalLoginRepository>(factory => factory.GetRequiredService <ExternalLoginRepository>()); builder.Services.AddUnique <IExternalLoginWithKeyRepository>(factory => factory.GetRequiredService <ExternalLoginRepository>()); builder.Services.AddUnique <ILanguageRepository, LanguageRepository>(); builder.Services.AddUnique <IMacroRepository, MacroRepository>(); builder.Services.AddUnique <IMediaRepository, MediaRepository>(); builder.Services.AddUnique <IMediaTypeContainerRepository, MediaTypeContainerRepository>(); builder.Services.AddUnique <IMediaTypeRepository, MediaTypeRepository>(); builder.Services.AddUnique <IMemberGroupRepository, MemberGroupRepository>(); builder.Services.AddUnique <IMemberRepository, MemberRepository>(); builder.Services.AddUnique <IMemberTypeContainerRepository, MemberTypeContainerRepository>(); builder.Services.AddUnique <IMemberTypeRepository, MemberTypeRepository>(); builder.Services.AddUnique <INotificationsRepository, NotificationsRepository>(); builder.Services.AddUnique <IPublicAccessRepository, PublicAccessRepository>(); builder.Services.AddUnique <IRedirectUrlRepository, RedirectUrlRepository>(); builder.Services.AddUnique <IRelationRepository, RelationRepository>(); builder.Services.AddUnique <ITrackedReferencesRepository, TrackedReferencesRepository>(); builder.Services.AddUnique <IRelationTypeRepository, RelationTypeRepository>(); builder.Services.AddUnique <IServerRegistrationRepository, ServerRegistrationRepository>(); builder.Services.AddUnique <ITagRepository, TagRepository>(); builder.Services.AddUnique <ITemplateRepository, TemplateRepository>(); builder.Services.AddUnique <IUserGroupRepository, UserGroupRepository>(); builder.Services.AddUnique <IUserRepository, UserRepository>(); builder.Services.AddUnique <IConsentRepository, ConsentRepository>(); builder.Services.AddUnique <IPartialViewMacroRepository, PartialViewMacroRepository>(); builder.Services.AddUnique <IPartialViewRepository, PartialViewRepository>(); builder.Services.AddUnique <IScriptRepository, ScriptRepository>(); builder.Services.AddUnique <IStylesheetRepository, StylesheetRepository>(); builder.Services.AddUnique <IContentTypeCommonRepository, ContentTypeCommonRepository>(); builder.Services.AddUnique <IKeyValueRepository, KeyValueRepository>(); builder.Services.AddUnique <IInstallationRepository, InstallationRepository>(); builder.Services.AddUnique <IUpgradeCheckRepository, UpgradeCheckRepository>(); builder.Services.AddUnique <ILogViewerQueryRepository, LogViewerQueryRepository>(); builder.Services.AddUnique <INodeCountRepository, NodeCountRepository>(); builder.Services.AddUnique <IIdKeyMapRepository, IdKeyMapRepository>(); return(builder); }
/// <summary> /// Adds Identity support for Umbraco members /// </summary> public static IUmbracoBuilder AddMembersIdentity(this IUmbracoBuilder builder) { IServiceCollection services = builder.Services; // check if this has already been added, we cannot add twice but both front-end and back end // depend on this so it's possible it can be called twice. var distCacheBinder = new UniqueServiceDescriptor(typeof(IMemberManager), typeof(MemberManager), ServiceLifetime.Scoped); if (builder.Services.Contains(distCacheBinder)) { return(builder); } // NOTE: We are using AddIdentity which is going to add all of the default AuthN/AuthZ configurations = OK! // This will also add all of the default identity services for our user/role types that we aren't overriding = OK! // If a developer wishes to use Umbraco Members with different AuthN/AuthZ values, like different cookie values // or authentication scheme's then they can call the default identity configuration methods like ConfigureApplicationCookie. // BUT ... if a developer wishes to use the default auth schemes for entirely separate purposes alongside Umbraco members, // then we'll probably have to change this and make it more flexible like how we do for Users. Which means booting up // identity here with the basics and registering all of our own custom services. // Since we are using the defaults in v8 (and below) for members, I think using the default for members now is OK! services.AddIdentity <MemberIdentityUser, UmbracoIdentityRole>() .AddDefaultTokenProviders() .AddUserStore <IUserStore <MemberIdentityUser>, MemberUserStore>(factory => new MemberUserStore( factory.GetRequiredService <IMemberService>(), factory.GetRequiredService <IUmbracoMapper>(), factory.GetRequiredService <IScopeProvider>(), factory.GetRequiredService <IdentityErrorDescriber>(), factory.GetRequiredService <IPublishedSnapshotAccessor>(), factory.GetRequiredService <IExternalLoginWithKeyService>(), factory.GetRequiredService <ITwoFactorLoginService>() )) .AddRoleStore <MemberRoleStore>() .AddRoleManager <IMemberRoleManager, MemberRoleManager>() .AddMemberManager <IMemberManager, MemberManager>() .AddSignInManager <IMemberSignInManager, MemberSignInManager>() .AddErrorDescriber <MembersErrorDescriber>() .AddUserConfirmation <UmbracoUserConfirmation <MemberIdentityUser> >(); builder.AddNotificationHandler <MemberDeletedNotification, DeleteExternalLoginsOnMemberDeletedHandler>(); builder.AddNotificationAsyncHandler <MemberDeletedNotification, DeleteTwoFactorLoginsOnMemberDeletedHandler>(); services.ConfigureOptions <ConfigureMemberIdentityOptions>(); services.AddScoped <IMemberUserStore>(x => (IMemberUserStore)x.GetRequiredService <IUserStore <MemberIdentityUser> >()); services.AddScoped <IPasswordHasher <MemberIdentityUser>, MemberPasswordHasher>(); services.ConfigureOptions <ConfigureSecurityStampOptions>(); services.ConfigureOptions <ConfigureMemberCookieOptions>(); services.AddUnique <IMemberExternalLoginProviders, MemberExternalLoginProviders>(); return(builder); }
/// <summary> /// Adds Umbraco services /// </summary> internal static IUmbracoBuilder AddServices(this IUmbracoBuilder builder) { // register the service context builder.Services.AddUnique <ServiceContext>(); // register the special idk map builder.Services.AddUnique <IIdKeyMap, IdKeyMap>(); // register the services builder.Services.AddUnique <IPropertyValidationService, PropertyValidationService>(); builder.Services.AddUnique <IKeyValueService, KeyValueService>(); builder.Services.AddUnique <IPublicAccessService, PublicAccessService>(); builder.Services.AddUnique <IDomainService, DomainService>(); builder.Services.AddUnique <IAuditService, AuditService>(); builder.Services.AddUnique <ICacheInstructionService, CacheInstructionService>(); builder.Services.AddUnique <IBasicAuthService, BasicAuthService>(); builder.Services.AddUnique <ITagService, TagService>(); builder.Services.AddUnique <IContentService, ContentService>(); builder.Services.AddUnique <IContentVersionService, ContentVersionService>(); builder.Services.AddUnique <IContentVersionCleanupPolicy, DefaultContentVersionCleanupPolicy>(); builder.Services.AddUnique <IUserService, UserService>(); builder.Services.AddUnique <IMemberService, MemberService>(); builder.Services.AddUnique <IMediaService, MediaService>(); builder.Services.AddUnique <IContentTypeService, ContentTypeService>(); builder.Services.AddUnique <IContentTypeBaseServiceProvider, ContentTypeBaseServiceProvider>(); builder.Services.AddUnique <IMediaTypeService, MediaTypeService>(); builder.Services.AddUnique <IDataTypeService, DataTypeService>(); builder.Services.AddUnique <IFileService, FileService>(); builder.Services.AddUnique <ILocalizationService, LocalizationService>(); builder.Services.AddUnique <IPackagingService, PackagingService>(); builder.Services.AddUnique <IServerRegistrationService, ServerRegistrationService>(); builder.Services.AddUnique <IEntityService, EntityService>(); builder.Services.AddUnique <IRelationService, RelationService>(); builder.Services.AddUnique <IMacroService, MacroService>(); builder.Services.AddUnique <IMemberTypeService, MemberTypeService>(); builder.Services.AddUnique <IMemberGroupService, MemberGroupService>(); builder.Services.AddUnique <INotificationService, NotificationService>(); builder.Services.AddUnique <IExternalLoginService, ExternalLoginService>(); builder.Services.AddUnique <IRedirectUrlService, RedirectUrlService>(); builder.Services.AddUnique <IConsentService, ConsentService>(); builder.Services.AddTransient(SourcesFactory); builder.Services.AddUnique <ILocalizedTextService>(factory => new LocalizedTextService( factory.GetRequiredService <Lazy <LocalizedTextServiceFileSources> >(), factory.GetRequiredService <ILogger <LocalizedTextService> >())); builder.Services.AddUnique <IEntityXmlSerializer, EntityXmlSerializer>(); builder.Services.AddUnique <ConflictingPackageData>(); builder.Services.AddUnique <CompiledPackageXmlParser>(); builder.Services.AddUnique <ICreatedPackagesRepository>(factory => CreatePackageRepository(factory, "createdPackages.config")); builder.Services.AddUnique <PackageDataInstallation>(); builder.Services.AddUnique <IPackageInstallation, PackageInstallation>(); return(builder); }
public void AddNotificationsFromAssembly_Should_AddAsyncNotificationHandler_To_ServicesCollection( IUmbracoBuilder sut) { sut.AddNotificationsFromAssembly <CustomizationAttribute>(); var expectedHandlerType = typeof(INotificationAsyncHandler <ContentPublishedNotification>); var handler = sut.Services.SingleOrDefault(x => x.ServiceType == expectedHandlerType); Assert.NotNull(handler); Assert.That(handler.ImplementationType, Is.EqualTo(typeof(StubNotificationHandler))); }
public static IUmbracoBuilder AddWebMappingProfiles(this IUmbracoBuilder builder) { builder.WithCollectionBuilder <MapDefinitionCollectionBuilder>() .Add <ContentMapDefinition>() .Add <MediaMapDefinition>() .Add <MemberMapDefinition>(); builder.Services.AddTransient <CommonTreeNodeMapper>(); return(builder); }
public static IUmbracoBuilder SetBackOfficeUserManager <TUserManager>(this IUmbracoBuilder builder) where TUserManager : UserManager <BackOfficeIdentityUser>, IBackOfficeUserManager { Type customType = typeof(TUserManager); Type userManagerType = typeof(UserManager <BackOfficeIdentityUser>); builder.Services.Replace(ServiceDescriptor.Scoped(typeof(IBackOfficeUserManager), customType)); builder.Services.AddScoped(customType, services => services.GetRequiredService(userManagerType)); builder.Services.Replace(ServiceDescriptor.Scoped(userManagerType, customType)); return(builder); }
public static IUmbracoBuilder AddLogViewer(this IUmbracoBuilder builder) { builder.Services.AddSingleton <ILogViewerConfig, LogViewerConfig>(); builder.SetLogViewer <SerilogJsonLogViewer>(); builder.Services.AddSingleton <ILogViewer>(factory => new SerilogJsonLogViewer(factory.GetRequiredService <ILogger <SerilogJsonLogViewer> >(), factory.GetRequiredService <ILogViewerConfig>(), factory.GetRequiredService <ILoggingConfiguration>(), Log.Logger)); return(builder); }
public void Compose(IUmbracoBuilder builder) { builder.MapDefinitions().Add <MemberListItemMapDefinition>(); builder.Components().Append <MemberIndexingComponent>(); builder.AddNotificationHandler <ServerVariablesParsingNotification, ServerVariablesParsingHandler>(); builder.Services.AddUnique <IMemberExtendedService, MemberExtendedService>(); // Extend the Member Index fieldset. builder.Services.ConfigureOptions <ConfigureMemberIndexOptions>(); }
public static IUmbracoBuilder AddPersonalisationGroups(this IUmbracoBuilder builder, IConfiguration config) { var configSection = config.GetSection("Umbraco:PersonalisationGroups"); AddConfiguration(builder.Services, configSection); AddServices(builder.Services); AddProviders(builder.Services, configSection); return(builder); }
/// <summary> /// Add Umbraco configuration services and options /// </summary> public static IUmbracoBuilder AddConfiguration(this IUmbracoBuilder builder) { // Register configuration validators. builder.Services.AddSingleton <IValidateOptions <ContentSettings>, ContentSettingsValidator>(); builder.Services.AddSingleton <IValidateOptions <GlobalSettings>, GlobalSettingsValidator>(); builder.Services.AddSingleton <IValidateOptions <HealthChecksSettings>, HealthChecksSettingsValidator>(); builder.Services.AddSingleton <IValidateOptions <RequestHandlerSettings>, RequestHandlerSettingsValidator>(); builder.Services.AddSingleton <IValidateOptions <UnattendedSettings>, UnattendedSettingsValidator>(); // Register configuration sections. builder .AddUmbracoOptions <ModelsBuilderSettings>() .AddUmbracoOptions <ConnectionStrings>() .AddUmbracoOptions <ActiveDirectorySettings>() .AddUmbracoOptions <ContentSettings>() .AddUmbracoOptions <CoreDebugSettings>() .AddUmbracoOptions <ExceptionFilterSettings>() .AddUmbracoOptions <GlobalSettings>(optionsBuilder => optionsBuilder.PostConfigure(options => { if (string.IsNullOrEmpty(options.UmbracoMediaPhysicalRootPath)) { options.UmbracoMediaPhysicalRootPath = options.UmbracoMediaPath; } })) .AddUmbracoOptions <HealthChecksSettings>() .AddUmbracoOptions <HostingSettings>() .AddUmbracoOptions <ImagingSettings>() .AddUmbracoOptions <IndexCreatorSettings>() .AddUmbracoOptions <KeepAliveSettings>() .AddUmbracoOptions <LoggingSettings>() .AddUmbracoOptions <MemberPasswordConfigurationSettings>() .AddUmbracoOptions <NuCacheSettings>() .AddUmbracoOptions <RequestHandlerSettings>() .AddUmbracoOptions <RuntimeSettings>() .AddUmbracoOptions <SecuritySettings>() .AddUmbracoOptions <TourSettings>() .AddUmbracoOptions <TypeFinderSettings>() .AddUmbracoOptions <UserPasswordConfigurationSettings>() .AddUmbracoOptions <WebRoutingSettings>() .AddUmbracoOptions <UmbracoPluginSettings>() .AddUmbracoOptions <UnattendedSettings>() .AddUmbracoOptions <RichTextEditorSettings>() .AddUmbracoOptions <BasicAuthSettings>() .AddUmbracoOptions <RuntimeMinificationSettings>() .AddUmbracoOptions <LegacyPasswordMigrationSettings>() .AddUmbracoOptions <PackageMigrationSettings>() .AddUmbracoOptions <ContentDashboardSettings>() .AddUmbracoOptions <HelpPageSettings>(); builder.Services.Configure <RequestHandlerSettings>(options => options.MergeReplacements(builder.Config)); return(builder); }
public void Compose(IUmbracoBuilder builder) { var converters = GetType().Assembly.GetTypes().Where(x => x.Implements <IConverter>() && x.IsClass); foreach (var converter in converters) { builder.Converters().Append(converter); } builder.BlockConverters().Append <DefaultBlockConverter>(); }
/// <summary> /// Adds Umbraco back office authorization policies /// </summary> public static IUmbracoBuilder AddBackOfficeAuthorizationPolicies(this IUmbracoBuilder builder, string backOfficeAuthenticationScheme = Constants.Security.BackOfficeAuthenticationType) { builder.AddBackOfficeAuthorizationPoliciesInternal(backOfficeAuthenticationScheme); builder.Services.AddSingleton <IAuthorizationHandler, FeatureAuthorizeHandler>(); builder.Services.AddAuthorization(options => options.AddPolicy(AuthorizationPolicies.UmbracoFeatureEnabled, policy => policy.Requirements.Add(new FeatureAuthorizeRequirement()))); return(builder); }
/// <summary> /// Add Umbraco hosted services /// </summary> public static IUmbracoBuilder AddHostedServices(this IUmbracoBuilder builder) { builder.Services.AddHostedService <QueuedHostedService>(); builder.Services.AddHostedService <HealthCheckNotifier>(); builder.Services.AddHostedService <KeepAlive>(); builder.Services.AddHostedService <LogScrubber>(); builder.Services.AddHostedService <ScheduledPublishing>(); builder.Services.AddHostedService <TempFileCleanup>(); builder.Services.AddHostedService <InstructionProcessTask>(); builder.Services.AddHostedService <TouchServerTask>(); builder.Services.AddHostedService <ReportSiteTask>(); return(builder); }
/// <summary> /// Adds the ModelsBuilder dashboard, but only when not in production mode. /// </summary> internal static IUmbracoBuilder TryAddModelsBuilderDashboard(this IUmbracoBuilder builder) { if (builder.Config.GetRuntimeMode() == RuntimeMode.Production) { builder.RemoveModelsBuilderDashboard(); } else { builder.AddModelsBuilderDashboard(); } return(builder); }
private static void AddAsyncNotificationHandlers <T>(IUmbracoBuilder self) { List <Type> notificationHandlers = GetAsyncNotificationHandlers <T>(); foreach (Type notificationHandler in notificationHandlers) { List <Type> handlerImplementations = GetAsyncNotificationHandlerImplementations <T>(notificationHandler); foreach (Type handler in handlerImplementations) { RegisterNotificationHandler(self, handler, notificationHandler); } } }
public static IUmbracoBuilder AdduSyncStaticAssets(this IUmbracoBuilder builder) { // don't add if the filter is already there . if (builder.ManifestFilters().Has <uSyncAssetManifestFilter>()) { return(builder); } // add the package manifest programatically. builder.ManifestFilters().Append <uSyncAssetManifestFilter>(); return(builder); }
private static void AddNotificationHandlers <T>(IUmbracoBuilder self) { var notificationHandlers = GetNotificationHandlers <T>(); foreach (var notificationHandler in notificationHandlers) { var handlerImplementations = GetNotificationHandlerImplementations <T>(notificationHandler); foreach (var implementation in handlerImplementations) { RegisterNotificationHandler(self, implementation, notificationHandler); } } }
public static IUmbracoBuilder AdduSyncAutoTemplates(this IUmbracoBuilder builder) { // check to see if we've been registerd before. if (builder.Services.FindIndex(x => x.ServiceType == typeof(TemplateWatcher)) != -1) { return(builder); } builder.Services.AddSingleton <TemplateWatcher>(); builder.AddNotificationHandler <UmbracoApplicationStartingNotification, AutoTemplateNotificationHandler>(); builder.AddNotificationHandler <TemplateSavingNotification, AutoTemplateNotificationHandler>(); return(builder); }
public static IUmbracoBuilder AddTelemetryProviders(this IUmbracoBuilder builder) { builder.Services.AddTransient <IDetailedTelemetryProvider, ContentTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, DomainTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, ExamineTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, LanguagesTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, MacroTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, MediaTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, NodeCountTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, PropertyEditorTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, UserTelemetryProvider>(); builder.Services.AddTransient <IDetailedTelemetryProvider, SystemInformationTelemetryProvider>(); return(builder); }
// TODO: Does this need to exist and/or be public? public static IUmbracoBuilder AddWebServer(this IUmbracoBuilder builder) { // TODO: We need to figure out why this is needed and fix those endpoints to not need them, we don't want to change global things // If using Kestrel: https://stackoverflow.com/a/55196057 builder.Services.Configure <KestrelServerOptions>(options => { options.AllowSynchronousIO = true; }); builder.Services.Configure <IISServerOptions>(options => { options.AllowSynchronousIO = true; }); return(builder); }
protected override void CustomTestSetup(IUmbracoBuilder builder) { builder.AddNuCache(); builder.Services.AddUnique <IServerMessenger, LocalServerMessenger>(); builder .AddNotificationHandler <DictionaryItemDeletedNotification, DistributedCacheBinder>() .AddNotificationHandler <DictionaryItemSavedNotification, DistributedCacheBinder>() .AddNotificationHandler <LanguageSavedNotification, DistributedCacheBinder>() .AddNotificationHandler <LanguageDeletedNotification, DistributedCacheBinder>() .AddNotificationHandler <UserSavedNotification, DistributedCacheBinder>() .AddNotificationHandler <LanguageDeletedNotification, DistributedCacheBinder>() .AddNotificationHandler <MemberGroupDeletedNotification, DistributedCacheBinder>() .AddNotificationHandler <MemberGroupSavedNotification, DistributedCacheBinder>(); builder.AddNotificationHandler <LanguageSavedNotification, PublishedSnapshotServiceEventHandler>(); }
public static IUmbracoBuilder AddMvcAndRazor(this IUmbracoBuilder builder, Action <IMvcBuilder>?mvcBuilding = null) { // TODO: We need to figure out if we can work around this because calling AddControllersWithViews modifies the global app and order is very important // this will directly affect developers who need to call that themselves. IMvcBuilder mvcBuilder = builder.Services.AddControllersWithViews(); if (builder.Config.GetRuntimeMode() != RuntimeMode.Production) { mvcBuilder.AddRazorRuntimeCompilation(); } mvcBuilding?.Invoke(mvcBuilder); return(builder); }
/// <summary> /// Add required services for SQLite support. /// </summary> public static IUmbracoBuilder AddUmbracoSqliteSupport(this IUmbracoBuilder builder) { // TryAddEnumerable takes both TService and TImplementation into consideration (unlike TryAddSingleton) builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <ISqlSyntaxProvider, SqliteSyntaxProvider>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IBulkSqlInsertProvider, SqliteBulkSqlInsertProvider>()); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <IDatabaseCreator, SqliteDatabaseCreator>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IProviderSpecificMapperFactory, SqliteSpecificMapperFactory>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IDatabaseProviderMetadata, SqliteDatabaseProviderMetadata>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IDistributedLockingMechanism, SqliteDistributedLockingMechanism>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IProviderSpecificInterceptor, SqliteAddPreferDeferredInterceptor>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IProviderSpecificInterceptor, SqliteAddMiniProfilerInterceptor>()); builder.Services.TryAddEnumerable(ServiceDescriptor .Singleton <IProviderSpecificInterceptor, SqliteAddRetryPolicyInterceptor>()); DbProviderFactories.UnregisterFactory(Constants.ProviderName); DbProviderFactories.RegisterFactory(Constants.ProviderName, SqliteFactory.Instance); // Remove this registration in Umbraco 12 DbProviderFactories.UnregisterFactory(Constants.ProviderNameLegacy); DbProviderFactories.RegisterFactory(Constants.ProviderNameLegacy, SqliteFactory.Instance); // Prevent accidental creation of SQLite database files builder.Services.PostConfigureAll <ConnectionStrings>(options => { // Skip empty connection string and other providers if (!options.IsConnectionStringConfigured() || (options.ProviderName != Constants.ProviderName && options.ProviderName != Constants.ProviderNameLegacy)) { return; } var connectionStringBuilder = new SqliteConnectionStringBuilder(options.ConnectionString); if (connectionStringBuilder.Mode == SqliteOpenMode.ReadWriteCreate) { connectionStringBuilder.Mode = SqliteOpenMode.ReadWrite; options.ConnectionString = connectionStringBuilder.ConnectionString; } }); return(builder); }
public static IUmbracoBuilder AddMvcAndRazor(this IUmbracoBuilder builder, Action <IMvcBuilder>?mvcBuilding = null) { // TODO: We need to figure out if we can work around this because calling AddControllersWithViews modifies the global app and order is very important // this will directly affect developers who need to call that themselves. // We need to have runtime compilation of views when using umbraco. We could consider having only this when a specific config is set. // But as far as I can see, there are still precompiled views, even when this is activated, so maybe it is okay. IMvcBuilder mvcBuilder = builder.Services .AddControllersWithViews(); FixForDotnet6Preview1(builder.Services); mvcBuilder.AddRazorRuntimeCompilation(); mvcBuilding?.Invoke(mvcBuilder); return(builder); }
public static IUmbracoBuilder AdduSyncFirstBoot(this IUmbracoBuilder builder) { builder.Services.PostConfigure <GlobalSettings>(settings => { if (settings.NoNodesViewPath.InvariantEquals(defaultNoNodesPath)) { // if the default hasn't changed, put in the uSync version settings.NoNodesViewPath = noNodesPath; } }); // add notification handler to do the actual first boot run. builder.AddNotificationHandler <UmbracoApplicationStartingNotification, FirstBootAppStartingHandler>(); return(builder); }
/// <summary> /// Adds Image Sharp with Umbraco settings /// </summary> public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder builder) { ImagingSettings imagingSettings = builder.Config.GetSection(Cms.Core.Constants.Configuration.ConfigImaging) .Get <ImagingSettings>() ?? new ImagingSettings(); builder.Services.AddImageSharp(options => { // The configuration is set using ImageSharpConfigurationOptions options.BrowserMaxAge = imagingSettings.Cache.BrowserMaxAge; options.CacheMaxAge = imagingSettings.Cache.CacheMaxAge; options.CachedNameLength = imagingSettings.Cache.CachedNameLength; // Use configurable maximum width and height (overwrite ImageSharps default) options.OnParseCommandsAsync = context => { if (context.Commands.Count == 0) { return(Task.CompletedTask); } uint width = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), context.Culture); uint height = context.Parser.ParseValue <uint>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture); if (width > imagingSettings.Resize.MaxWidth || height > imagingSettings.Resize.MaxHeight) { context.Commands.Remove(ResizeWebProcessor.Width); context.Commands.Remove(ResizeWebProcessor.Height); } return(Task.CompletedTask); }; }) .Configure <PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder)) // We need to add CropWebProcessor before ResizeWebProcessor (until https://github.com/SixLabors/ImageSharp.Web/issues/182 is fixed) .RemoveProcessor <ResizeWebProcessor>() .RemoveProcessor <FormatWebProcessor>() .RemoveProcessor <BackgroundColorWebProcessor>() .RemoveProcessor <JpegQualityWebProcessor>() .AddProcessor <CropWebProcessor>() .AddProcessor <ResizeWebProcessor>() .AddProcessor <FormatWebProcessor>() .AddProcessor <BackgroundColorWebProcessor>() .AddProcessor <JpegQualityWebProcessor>(); builder.Services.AddTransient <IConfigureOptions <ImageSharpMiddlewareOptions>, ImageSharpConfigurationOptions>(); return(builder.Services); }