2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-01-04 15:43:30 +11:00
|
|
|
using Microsoft.AspNetCore.Mvc.Razor;
|
2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Umbraco.Core.DependencyInjection;
|
2020-12-24 18:11:16 +11:00
|
|
|
using Umbraco.Extensions;
|
2020-12-24 14:29:26 +11:00
|
|
|
using Umbraco.Infrastructure.DependencyInjection;
|
2020-12-23 13:06:22 +11:00
|
|
|
using Umbraco.Infrastructure.PublishedCache.DependencyInjection;
|
2021-02-01 16:53:24 +11:00
|
|
|
using Umbraco.ModelsBuilder.Embedded.DependencyInjection;
|
2021-01-08 15:27:07 +11:00
|
|
|
using Umbraco.Web.Common.Routing;
|
2020-12-24 18:11:16 +11:00
|
|
|
using Umbraco.Web.Website.Collections;
|
2020-12-23 12:02:23 +11:00
|
|
|
using Umbraco.Web.Website.Controllers;
|
|
|
|
|
using Umbraco.Web.Website.Routing;
|
|
|
|
|
using Umbraco.Web.Website.ViewEngines;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Website.DependencyInjection
|
|
|
|
|
{
|
|
|
|
|
/// <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-01-08 02:10:13 +11:00
|
|
|
builder.Services.AddSingleton<HijackedRouteEvaluator>();
|
|
|
|
|
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-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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|