Files
Umbraco-CMS/src/Umbraco.Web.UI.NetCore/Startup.cs

67 lines
2.2 KiB
C#
Raw Normal View History

2020-02-18 08:32:06 +01:00
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
2020-03-16 14:02:08 +01:00
using Microsoft.Extensions.Configuration;
2020-02-18 08:32:06 +01:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
2020-02-18 08:32:06 +01:00
namespace Umbraco.Cms.Web.UI.NetCore
2020-02-18 08:32:06 +01:00
{
public class Startup
{
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
/// <summary>
2020-12-04 13:09:08 +11:00
/// Initializes a new instance of the <see cref="Startup"/> class.
/// </summary>
/// <param name="webHostEnvironment">The Web Host Environment</param>
/// <param name="config">The Configuration</param>
/// <remarks>
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337
/// </remarks>
public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
{
_env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
_config = config ?? throw new ArgumentNullException(nameof(config));
}
2020-12-04 13:09:08 +11:00
/// <summary>
/// Configures the services
/// </summary>
/// <remarks>
/// This method gets called by the runtime. Use this method to add services to the container.
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
/// </remarks>
2020-02-18 08:32:06 +01:00
public void ConfigureServices(IServiceCollection services)
2020-05-15 15:21:15 +01:00
{
2020-12-04 13:09:08 +11:00
#pragma warning disable IDE0022 // Use expression body for methods
2020-11-20 12:24:16 +00:00
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
.Build();
2020-12-04 13:09:08 +11:00
#pragma warning restore IDE0022 // Use expression body for methods
2020-02-18 08:32:06 +01:00
}
2020-12-04 13:09:08 +11:00
/// <summary>
/// Configures the application
/// </summary>
public void Configure(IApplicationBuilder app)
2020-02-18 08:32:06 +01:00
{
if (_env.IsDevelopment())
2020-02-18 08:32:06 +01:00
{
app.UseDeveloperExceptionPage();
}
2020-12-08 16:33:50 +11:00
app.UseUmbracoBackOffice();
app.UseUmbracoWebsite();
2020-02-18 08:32:06 +01:00
}
}
}