2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
2021-02-09 10:22:42 +01:00
|
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
2021-03-01 12:51:07 +11:00
|
|
|
using Umbraco.Cms.Core.Security;
|
2021-02-12 10:41:07 +01:00
|
|
|
using Umbraco.Cms.Infrastructure.DependencyInjection;
|
2021-02-10 11:42:04 +01:00
|
|
|
using Umbraco.Cms.Web.Common.Routing;
|
2021-03-01 12:51:07 +11:00
|
|
|
using Umbraco.Cms.Web.Common.Security;
|
2021-02-10 14:21:48 +01:00
|
|
|
using Umbraco.Cms.Web.Website.Collections;
|
|
|
|
|
using Umbraco.Cms.Web.Website.Controllers;
|
|
|
|
|
using Umbraco.Cms.Web.Website.Routing;
|
|
|
|
|
using Umbraco.Cms.Web.Website.ViewEngines;
|
2020-12-23 12:02:23 +11:00
|
|
|
|
2021-02-10 14:21:48 +01:00
|
|
|
namespace Umbraco.Extensions
|
2020-12-23 12:02:23 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="IUmbracoBuilder"/> extensions for umbraco front-end website
|
|
|
|
|
/// </summary>
|
2020-12-23 12:11:38 +11:00
|
|
|
public static class UmbracoBuilderExtensions
|
2020-12-23 12:02:23 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add services for the umbraco front-end website
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IUmbracoBuilder AddWebsite(this IUmbracoBuilder builder)
|
|
|
|
|
{
|
2020-12-24 18:11:16 +11:00
|
|
|
builder.WithCollectionBuilder<SurfaceControllerTypeCollectionBuilder>()
|
|
|
|
|
.Add(builder.TypeLoader.GetSurfaceControllers());
|
|
|
|
|
|
2021-01-04 15:43:30 +11:00
|
|
|
// Configure MVC startup options for custom view locations
|
2021-01-14 23:14:35 +11:00
|
|
|
builder.Services.ConfigureOptions<RenderRazorViewEngineOptionsSetup>();
|
|
|
|
|
builder.Services.ConfigureOptions<PluginRazorViewEngineOptionsSetup>();
|
2020-12-23 12:02:23 +11:00
|
|
|
|
|
|
|
|
// Wraps all existing view engines in a ProfilerViewEngine
|
|
|
|
|
builder.Services.AddTransient<IConfigureOptions<MvcViewOptions>, ProfilingViewEngineWrapperMvcViewOptionsSetup>();
|
|
|
|
|
|
|
|
|
|
// TODO figure out if we need more to work on load balanced setups
|
|
|
|
|
builder.Services.AddDataProtection();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddScoped<UmbracoRouteValueTransformer>();
|
2021-02-03 15:47:27 +11:00
|
|
|
builder.Services.AddSingleton<IControllerActionSearcher, ControllerActionSearcher>();
|
2021-01-08 02:10:13 +11:00
|
|
|
builder.Services.AddSingleton<IUmbracoRouteValuesFactory, UmbracoRouteValuesFactory>();
|
2020-12-23 12:02:23 +11:00
|
|
|
builder.Services.AddSingleton<IUmbracoRenderingDefaults, UmbracoRenderingDefaults>();
|
2021-01-13 11:08:48 +11:00
|
|
|
builder.Services.AddSingleton<IRoutableDocumentFilter, RoutableDocumentFilter>();
|
2020-12-23 12:02:23 +11:00
|
|
|
|
2021-03-01 12:51:07 +11:00
|
|
|
builder.Services.AddSingleton<FrontEndRoutes>();
|
2021-02-02 14:48:01 +11:00
|
|
|
|
2021-02-01 16:53:24 +11:00
|
|
|
builder
|
|
|
|
|
.AddDistributedCache()
|
|
|
|
|
.AddModelsBuilder();
|
2021-01-04 13:22:29 +11:00
|
|
|
|
2020-12-23 12:02:23 +11:00
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|