public static OrchardCoreBuilder AddTenantFeatures(this OrchardCoreBuilder builder, params string[] featureIds)
 {
     V_0            = new OrchardCoreBuilderExtensions.u003cu003ec__DisplayClass1_0();
     V_0.featureIds = featureIds;
     dummyVar0      = builder.ConfigureServices(new Action <IServiceCollection>(V_0.u003cAddTenantFeaturesu003eb__0), 0);
     return(builder);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds tenant level data protection services.
        /// </summary>
        private static void AddDataProtection(OrchardCoreBuilder builder)
        {
            builder.ConfigureServices((services, serviceProvider) =>
            {
                var settings = serviceProvider.GetRequiredService <ShellSettings>();
                var options  = serviceProvider.GetRequiredService <IOptions <ShellOptions> >();

                // The 'FileSystemXmlRepository' will create the directory, but only if it is not overridden.
                var directory = new DirectoryInfo(Path.Combine(
                                                      options.Value.ShellsApplicationDataPath,
                                                      options.Value.ShellsContainerName,
                                                      settings.Name, "DataProtection-Keys"));

                // Re-register the data protection services to be tenant-aware so that modules that internally
                // rely on IDataProtector/IDataProtectionProvider automatically get an isolated instance that
                // manages its own key ring and doesn't allow decrypting payloads encrypted by another tenant.
                // By default, the key ring is stored in the tenant directory of the configured App_Data path.
                var collection = new ServiceCollection()
                                 .AddDataProtection()
                                 .PersistKeysToFileSystem(directory)
                                 .SetApplicationName(settings.Name)
                                 .AddKeyManagementOptions(o => o.XmlEncryptor = o.XmlEncryptor ?? new NullXmlEncryptor())
                                 .Services;

                // Remove any previously registered options setups.
                services.RemoveAll <IConfigureOptions <KeyManagementOptions> >();
                services.RemoveAll <IConfigureOptions <DataProtectionOptions> >();

                services.Add(collection);
            });
        }
        private static void AddShellServices(OrchardCoreBuilder builder)
        {
            var services = builder.ApplicationServices;

            // Use a single tenant and all features by default
            services.AddHostingShellServices();
            services.AddAllFeaturesDescriptor();

            // Registers the application primary feature.
            services.AddTransient(sp => new ShellFeature
                                  (
                                      sp.GetRequiredService <IHostEnvironment>().ApplicationName, alwaysEnabled: true)
                                  );

            // Registers the application default feature.
            services.AddTransient(sp => new ShellFeature
                                  (
                                      Application.DefaultFeatureId, alwaysEnabled: true)
                                  );

            builder.ConfigureServices(shellServices =>
            {
                shellServices.AddTransient <IConfigureOptions <ShellContextOptions>, ShellContextOptionsSetup>();
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds tenant level caching services.
        /// </summary>
        public static OrchardCoreBuilder AddCaching(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddTransient <ITagCache, DefaultTagCache>();
                services.AddSingleton <ISignal, Signal>();
                services.AddScoped <ICacheContextManager, CacheContextManager>();
                services.AddScoped <ICacheScopeManager, CacheScopeManager>();

                services.AddScoped <ICacheContextProvider, FeaturesCacheContextProvider>();
                services.AddScoped <ICacheContextProvider, QueryCacheContextProvider>();
                services.AddScoped <ICacheContextProvider, RolesCacheContextProvider>();
                services.AddScoped <ICacheContextProvider, RouteCacheContextProvider>();
                services.AddScoped <ICacheContextProvider, UserCacheContextProvider>();
                services.AddScoped <ICacheContextProvider, KnownValueCacheContextProvider>();

                // IMemoryCache is registered at the tenant level so that there is one instance for each tenant.
                services.AddSingleton <IMemoryCache, MemoryCache>();

                // MemoryDistributedCache needs to be registered as a singleton as it owns a MemoryCache instance.
                services.AddSingleton <IDistributedCache, MemoryDistributedCache>();
            });

            return(builder);
        }
Exemplo n.º 5
0
        private static void AddDefaultServices(OrchardCoreBuilder builder)
        {
            var services = builder.ApplicationServices;

            services.AddLogging();
            services.AddOptions();

            // These services might be moved at a higher level if no components from OrchardCore needs them.
            services.AddLocalization();

            // For performance, prevents the 'ResourceManagerStringLocalizer' from being used.
            // Also support pluralization.
            services.AddSingleton <IStringLocalizerFactory, NullStringLocalizerFactory>();
            services.AddSingleton <IHtmlLocalizerFactory, NullHtmlLocalizerFactory>();

            services.AddWebEncoders();

            services.AddHttpContextAccessor();
            services.AddSingleton <IClock, Clock>();
            services.AddScoped <ILocalClock, LocalClock>();

            services.AddScoped <ILocalizationService, DefaultLocalizationService>();
            services.AddScoped <ICalendarManager, DefaultCalendarManager>();
            services.AddScoped <ICalendarSelector, DefaultCalendarSelector>();

            services.AddSingleton <IPoweredByMiddlewareOptions, PoweredByMiddlewareOptions>();

            services.AddScoped <IOrchardHelper, DefaultOrchardHelper>();

            builder.ConfigureServices(s =>
            {
                s.AddSingleton <ILock, LocalLock>();
                s.AddSingleton <IDistributedLock>(sp => sp.GetRequiredService <LocalLock>());
            });
        }
        /// <summary>
        /// Adds host and tenant level antiforgery services.
        /// </summary>
        private static void AddAntiForgery(OrchardCoreBuilder builder)
        {
            builder.ApplicationServices.AddAntiforgery();

            builder.ConfigureServices((services, serviceProvider) =>
            {
                var settings = serviceProvider.GetRequiredService <ShellSettings>();

                var cookieName = "orchantiforgery_" + settings.Name;

                // If uninitialized, we use the host services.
                if (settings.State == TenantState.Uninitialized)
                {
                    // And delete a cookie that may have been created by another instance.
                    var httpContextAccessor = serviceProvider.GetRequiredService <IHttpContextAccessor>();
                    httpContextAccessor.HttpContext.Response.Cookies.Delete(cookieName);
                    return;
                }

                // Re-register the antiforgery  services to be tenant-aware.
                var collection = new ServiceCollection()
                                 .AddAntiforgery(options =>
                {
                    options.Cookie.Name = cookieName;

                    // Don't set the cookie builder 'Path' so that it uses the 'IAuthenticationFeature' value
                    // set by the pipeline and comming from the request 'PathBase' which already ends with the
                    // tenant prefix but may also start by a path related e.g to a virtual folder.
                });

                services.Add(collection);
            });
        }
Exemplo n.º 7
0
        public static OrchardCoreBuilder AddDataContext(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddScoped <IDataMigrationManager, DataMigrationManager>();
                services.AddScoped <IModularTenantEvents, AutoDataMigration>();
                services.AddScoped <IDataMigrator, DataMigrator>();

                services.TryAddDataProvider(name: "Microsoft SQLServer", provider: "SqlConnection");
                services.TryAddDataProvider(
                    name: "MySql Database",
                    provider: "MySql",
                    sample: "Server=localhost;Port=3306;Database=dbname;User=root;Password=;");

                services.AddSingleton <IStore>(sp =>
                {
                    return(new Store(sp));
                });

                services.AddScoped <IDbContext>(sp =>
                {
                    // var typeConfigs = sp.GetServices<IEntityTypeConfigurationProvider>()
                    //     .InvokeAsync(provider => provider.GetEntityTypeConfigurationsAsync(), null)
                    //     .Result;
                    return(sp.GetService <IStore>()?.CreateDbContext(sp)); // .CreateDbContext(typeConfigs.ToArray());
                });
            });

            return(builder);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds isolated tenant level routing services.
        /// </summary>
        private static void AddRouting(OrchardCoreBuilder builder)
        {
            // 'AddRouting()' is called by the host.

            builder.ConfigureServices(collection =>
            {
                // The routing system is not tenant aware and uses a global list of endpoint data sources which is
                // setup by the default configuration of 'RouteOptions' and mutated on each call of 'UseEndPoints()'.
                // So, we need isolated routing singletons (and a default configuration) per tenant.

                var implementationTypesToRemove = new ServiceCollection().AddRouting()
                                                  .Where(sd => sd.Lifetime == ServiceLifetime.Singleton || sd.ServiceType == typeof(IConfigureOptions <RouteOptions>))
                                                  .Select(sd => sd.GetImplementationType())
                                                  .ToArray();

                var descriptorsToRemove = collection
                                          .Where(sd => (sd is ClonedSingletonDescriptor || sd.ServiceType == typeof(IConfigureOptions <RouteOptions>)) &&
                                                 implementationTypesToRemove.Contains(sd.GetImplementationType()))
                                          .ToArray();

                foreach (var descriptor in descriptorsToRemove)
                {
                    collection.Remove(descriptor);
                }

                collection.AddRouting();
            },
                                      order: int.MinValue + 100);
        }
        /// <summary>
        /// Adds tenant level services for managing liquid view template files.
        /// </summary>
        public static OrchardCoreBuilder AddLiquidViews(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.TryAddEnumerable(
                    ServiceDescriptor.Transient <IConfigureOptions <LiquidViewOptions>,
                                                 LiquidViewOptionsSetup>());

                services.TryAddEnumerable(
                    ServiceDescriptor.Transient <IConfigureOptions <ShapeTemplateOptions>,
                                                 LiquidShapeTemplateOptionsSetup>());

                services.TryAddSingleton <ILiquidViewFileProviderAccessor, LiquidViewFileProviderAccessor>();
                services.AddSingleton <IApplicationFeatureProvider <ViewsFeature>, LiquidViewsFeatureProvider>();
                services.AddScoped <IRazorViewExtensionProvider, LiquidViewExtensionProvider>();
                services.AddSingleton <LiquidTagHelperFactory>();

                services.AddScoped <ILiquidTemplateEventHandler, RequestLiquidTemplateEventHandler>();
                services.AddScoped <ILiquidTemplateEventHandler, CultureLiquidTemplateEventHandler>();

                services.AddLiquidFilter <AppendVersionFilter>("append_version");
                services.AddLiquidFilter <ResourceUrlFilter>("resource_url");
                services.AddLiquidFilter <SanitizeHtmlFilter>("sanitize_html");
                services.AddScoped <ITokenProvider, RequestTokens>();
            });

            return(builder);
        }
        /// <summary>
        /// Configures ApiExplorer at the tenant level using <see cref="Endpoint.Metadata"/>.
        /// </summary>
        private static void AddEndpointsApiExplorer(OrchardCoreBuilder builder)
        {
            // 'AddEndpointsApiExplorer()' is called by the host.

            builder.ConfigureServices(collection =>
            {
                // Remove the related host singletons as they are not tenant aware.
                var descriptorsToRemove = collection
                                          .Where(sd => sd is ClonedSingletonDescriptor &&
                                                 (sd.ServiceType == typeof(IActionDescriptorCollectionProvider) ||
                                                  sd.ServiceType == typeof(IApiDescriptionGroupCollectionProvider)))
                                          .ToArray();

                foreach (var descriptor in descriptorsToRemove)
                {
                    collection.Remove(descriptor);
                }

#if NET6_0_OR_GREATER
                // Configure ApiExplorer at the tenant level.
                collection.AddEndpointsApiExplorer();
#endif
            },
                                      order: Int32.MinValue + 100);
        }
        private static void AddExtensionServices(OrchardCoreBuilder builder)
        {
            builder.ApplicationServices.AddExtensionManagerHost();

            builder.ConfigureServices(services =>
            {
                services.AddExtensionManager();
            });
        }
        /// <summary>
        /// Adds html script sanitization services.
        /// </summary>
        /// <param name="builder">The <see cref="OrchardCoreBuilder"/>.</param>
        public static OrchardCoreBuilder AddHtmlSanitizer(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddScoped <IHtmlSanitizerService, HtmlSanitizerService>();
            });

            return(builder);
        }
        /// <summary>
        /// Adds e-mail address validator service.
        /// </summary>
        /// <param name="builder">The <see cref="OrchardCoreBuilder"/>.</param>
        public static OrchardCoreBuilder AddEmailAddressValidator(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddTransient <IEmailAddressValidator, EmailAddressValidator>();
            });

            return(builder);
        }
        /// <summary>
        /// Adds tenant level deferred tasks services.
        /// </summary>
        public static OrchardCoreBuilder AddDeferredTasks(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.TryAddScoped <IDeferredTaskEngine, DeferredTaskEngine>();
                services.TryAddScoped <IDeferredTaskState, HttpContextTaskState>();
            });

            return(builder);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Adds tenant level background tasks services.
        /// </summary>
        public static OrchardCoreBuilder AddBackgroundTasks(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.TryAddSingleton <IBackgroundTaskService, BackgroundTaskService>();
                services.AddScoped <BackgroundTasksStarter>();
                services.AddScoped <IModularTenantEvents>(sp => sp.GetRequiredService <BackgroundTasksStarter>());
            });

            return(builder);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Adds tenant level configuration to serve static files from modules
        /// </summary>
        private static void AddStaticFiles(OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddSingleton <IModuleStaticFileProvider>(serviceProvider =>
                {
                    var env        = serviceProvider.GetRequiredService <IHostEnvironment>();
                    var appContext = serviceProvider.GetRequiredService <IApplicationContext>();

                    IModuleStaticFileProvider fileProvider;
                    if (env.IsDevelopment())
                    {
                        var fileProviders = new List <IStaticFileProvider>
                        {
                            new ModuleProjectStaticFileProvider(appContext),
                            new ModuleEmbeddedStaticFileProvider(appContext)
                        };
                        fileProvider = new ModuleCompositeStaticFileProvider(fileProviders);
                    }
                    else
                    {
                        fileProvider = new ModuleEmbeddedStaticFileProvider(appContext);
                    }
                    return(fileProvider);
                });

                services.AddSingleton <IStaticFileProvider>(serviceProvider =>
                {
                    return(serviceProvider.GetRequiredService <IModuleStaticFileProvider>());
                });
            });

            builder.Configure((app, routes, serviceProvider) =>
            {
                var fileProvider = serviceProvider.GetRequiredService <IModuleStaticFileProvider>();

                var options = serviceProvider.GetRequiredService <IOptions <StaticFileOptions> >().Value;

                options.RequestPath  = "";
                options.FileProvider = fileProvider;

                var shellConfiguration = serviceProvider.GetRequiredService <IShellConfiguration>();

                var cacheControl = shellConfiguration.GetValue("StaticFileOptions:CacheControl", "public, max-age=2592000, s-max-age=31557600");

                // Cache static files for a year as they are coming from embedded resources and should not vary
                options.OnPrepareResponse = ctx =>
                {
                    ctx.Context.Response.Headers[HeaderNames.CacheControl] = cacheControl;
                };

                app.UseStaticFiles(options);
            });
        }
Exemplo n.º 17
0
        /// <summary>
        /// Adds scripting services.
        /// </summary>
        /// <param name="builder">The <see cref="OrchardCoreBuilder"/>.</param>
        public static OrchardCoreBuilder AddScripting(this OrchardCoreBuilder builder)
        {
            builder.ApplicationServices.AddSingleton <IGlobalMethodProvider, CommonGeneratorMethods>();
            builder.ApplicationServices.AddSingleton <IScriptingEngine, FilesScriptEngine>();

            builder.ConfigureServices(services =>
            {
                services.AddSingleton <IScriptingManager, DefaultScriptingManager>();
            });

            return(builder);
        }
Exemplo n.º 18
0
        private static void AddExtensionServices(OrchardCoreBuilder builder)
        {
            builder.ApplicationServices.AddSingleton <IModuleNamesProvider, AssemblyAttributeModuleNamesProvider>();
            builder.ApplicationServices.AddSingleton <IApplicationContext, ModularApplicationContext>();

            builder.ApplicationServices.AddExtensionManagerHost();

            builder.ConfigureServices(services =>
            {
                services.AddExtensionManager();
            });
        }
        /// <summary>
        /// Adds tenant level MVC services and configuration.
        /// </summary>
        public static OrchardCoreBuilder AddMvc(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(collection =>
            {
                // Allows a tenant to add its own route endpoint schemes for link generation.
                collection.AddSingleton <IEndpointAddressScheme <RouteValuesAddress>, ShellRouteValuesAddressScheme>();
            },
                                      // Need to be registered last.
                                      order: int.MaxValue - 100);

            return(builder.RegisterStartup <Startup>());
        }
        /// <summary>
        /// Adds a tenant level mvc filter which registers a Generator Meta Tag.
        /// </summary>
        public static OrchardCoreBuilder AddGeneratorTagFilter(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.Configure <MvcOptions>((options) =>
                {
                    options.Filters.Add(typeof(MetaGeneratorFilter));
                });
            });

            return(builder);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Registers at the tenant level a set of features which are always enabled.
        /// </summary>
        public static OrchardCoreBuilder AddTenantFeatures(this OrchardCoreBuilder builder, params string[] featureIds)
        {
            builder.ConfigureServices(services =>
            {
                foreach (var featureId in featureIds)
                {
                    services.AddTransient(sp => new ShellFeature(featureId, alwaysEnabled: true));
                }
            });

            return(builder);
        }
        /// <summary>
        /// Adds tenant level services for managing resources.
        /// </summary>
        public static OrchardCoreBuilder AddResourceManagement(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.TryAddScoped <IResourceManager, ResourceManager>();
                services.TryAddScoped <IRequireSettingsProvider, DefaultRequireSettingsProvider>();
                services.TryAddSingleton <IResourceManifestState, ResourceManifestState>();

                services.AddTagHelpers(typeof(ResourcesTagHelper).Assembly);
            });

            return(builder);
        }
 private static void AddRouting(OrchardCoreBuilder builder)
 {
     stackVariable0 = builder;
     stackVariable1 = Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__6_0;
     if (stackVariable1 == null)
     {
         dummyVar0      = stackVariable1;
         stackVariable1 = new Action <IServiceCollection>(Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9.u003cAddRoutingu003eb__6_0);
         Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__6_0 = stackVariable1;
     }
     dummyVar1 = stackVariable0.ConfigureServices(stackVariable1, -2147483548);
     return;
 }
 private static void AddDataProtection(OrchardCoreBuilder builder)
 {
     stackVariable0 = builder;
     stackVariable1 = Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__11_0;
     if (stackVariable1 == null)
     {
         dummyVar0      = stackVariable1;
         stackVariable1 = new Action <IServiceCollection, IServiceProvider>(Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9.u003cAddDataProtectionu003eb__11_0);
         Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__11_0 = stackVariable1;
     }
     dummyVar1 = stackVariable0.ConfigureServices(stackVariable1, 0);
     return;
 }
 private static void AddAntiForgery(OrchardCoreBuilder builder)
 {
     dummyVar0      = AntiforgeryServiceCollectionExtensions.AddAntiforgery(builder.get_ApplicationServices());
     stackVariable3 = builder;
     stackVariable4 = Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__7_0;
     if (stackVariable4 == null)
     {
         dummyVar1      = stackVariable4;
         stackVariable4 = new Action <IServiceCollection, IServiceProvider>(Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9.u003cAddAntiForgeryu003eb__7_0);
         Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__7_0 = stackVariable4;
     }
     dummyVar2 = stackVariable3.ConfigureServices(stackVariable4, 0);
     return;
 }
        /// <summary>
        /// Registers tenants defined in configuration.
        /// </summary>
        public static OrchardCoreBuilder WithTenants(this OrchardCoreBuilder builder)
        {
            var services = builder.ApplicationServices;

            services.AddSingleton <IShellsSettingsSources, ShellsSettingsSources>();
            services.AddSingleton <IShellsConfigurationSources, ShellsConfigurationSources>();
            services.AddSingleton <IShellConfigurationSources, ShellConfigurationSources>();
            services.AddTransient <IConfigureOptions <ShellOptions>, ShellOptionsSetup>();
            services.AddSingleton <IShellSettingsManager, ShellSettingsManager>();

            return(builder.ConfigureServices(s =>
            {
                s.AddScoped <IShellDescriptorManager, ConfiguredFeaturesShellDescriptorManager>();
            }));
        }
        /// <summary>
        /// Adds tenant level services to keep in sync any single <see cref="IDocument"/> between an <see cref="IDocumentStore"/> and a multi level cache.
        /// </summary>
        public static OrchardCoreBuilder AddDocumentManagement(this OrchardCoreBuilder builder)
        {
            return(builder.ConfigureServices(services =>
            {
                services.AddScoped(typeof(IDocumentManager <>), typeof(DocumentManager <>));
                services.AddScoped(typeof(IVolatileDocumentManager <>), typeof(VolatileDocumentManager <>));
                services.AddScoped(typeof(IDocumentManager <,>), typeof(DocumentManager <,>));

                services.TryAddEnumerable(ServiceDescriptor.Singleton <IConfigureOptions <DocumentOptions>, DocumentOptionsSetup>());

                services.AddScoped(typeof(IDocumentEntityManager <>), typeof(DocumentEntityManager <>));
                services.AddScoped(typeof(IVolatileDocumentEntityManager <>), typeof(VolatileDocumentEntityManager <>));
                services.AddScoped(typeof(IDocumentEntityManager <,>), typeof(DocumentEntityManager <,>));
            }));
        }
Exemplo n.º 28
0
 /// <summary>
 /// Adds backwards compatibility to the handling of SameSite cookies.
 /// </summary>
 private static void AddSameSiteCookieBackwardsCompatibility(OrchardCoreBuilder builder)
 {
     builder.ConfigureServices(services =>
     {
         services.Configure <CookiePolicyOptions>(options =>
         {
             options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
             options.OnAppendCookie        = cookieContext => CheckSameSiteBackwardsCompatiblity(cookieContext.Context, cookieContext.CookieOptions);
             options.OnDeleteCookie        = cookieContext => CheckSameSiteBackwardsCompatiblity(cookieContext.Context, cookieContext.CookieOptions);
         });
     })
     .Configure(app =>
     {
         app.UseCookiePolicy();
     });
 }
 private static void AddExtensionServices(OrchardCoreBuilder builder)
 {
     dummyVar0       = ServiceCollectionServiceExtensions.AddSingleton <IModuleNamesProvider, AssemblyAttributeModuleNamesProvider>(builder.get_ApplicationServices());
     dummyVar1       = ServiceCollectionServiceExtensions.AddSingleton <IApplicationContext, ModularApplicationContext>(builder.get_ApplicationServices());
     dummyVar2       = builder.get_ApplicationServices().AddExtensionManagerHost();
     stackVariable9  = builder;
     stackVariable10 = Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__4_0;
     if (stackVariable10 == null)
     {
         dummyVar3       = stackVariable10;
         stackVariable10 = new Action <IServiceCollection>(Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9.u003cAddExtensionServicesu003eb__4_0);
         Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.u003cu003ec.u003cu003e9__4_0 = stackVariable10;
     }
     dummyVar4 = stackVariable9.ConfigureServices(stackVariable10, 0);
     return;
 }
Exemplo n.º 30
0
        /// <summary>
        /// Adds html script sanitization services.
        /// </summary>
        /// <param name="builder">The <see cref="OrchardCoreBuilder"/>.</param>
        public static OrchardCoreBuilder AddHtmlSanitizer(this OrchardCoreBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                services.AddOptions <HtmlSanitizerOptions>();

                services.ConfigureHtmlSanitizer((sanitizer) =>
                {
                    sanitizer.AllowedAttributes.Add("class");
                });

                services.AddSingleton <IHtmlSanitizerService, HtmlSanitizerService>();
            });

            return(builder);
        }