diff --git a/src/Umbraco.Web.Website/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Website/DependencyInjection/UmbracoBuilderExtensions.cs new file mode 100644 index 0000000000..6f34ca6136 --- /dev/null +++ b/src/Umbraco.Web.Website/DependencyInjection/UmbracoBuilderExtensions.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Umbraco.Core.DependencyInjection; +using Umbraco.Infrastructure.PublishedCache.Extensions; +using Umbraco.Web.Website.Controllers; +using Umbraco.Web.Website.Routing; +using Umbraco.Web.Website.ViewEngines; + +namespace Umbraco.Web.Website.DependencyInjection +{ + /// + /// extensions for umbraco front-end website + /// + public static partial class UmbracoBuilderExtensions + { + /// + /// Add services for the umbraco front-end website + /// + public static IUmbracoBuilder AddWebsite(this IUmbracoBuilder builder) + { + // Set the render & plugin view engines (Super complicated, but this allows us to use the IServiceCollection + // to inject dependencies into the viewEngines) + builder.Services.AddTransient, RenderMvcViewOptionsSetup>(); + builder.Services.AddSingleton(); + builder.Services.AddTransient, PluginMvcViewOptionsSetup>(); + builder.Services.AddSingleton(); + + // Wraps all existing view engines in a ProfilerViewEngine + builder.Services.AddTransient, ProfilingViewEngineWrapperMvcViewOptionsSetup>(); + + // TODO figure out if we need more to work on load balanced setups + builder.Services.AddDataProtection(); + + builder.Services.AddScoped(); + builder.Services.AddSingleton(); + + builder.AddNuCache(); + + return builder; + } + + } +}