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;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
2020-12-08 12:32:19 +01:00
|
|
|
using Umbraco.Extensions;
|
2020-02-18 08:32:06 +01:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Web.UI.NetCore
|
2020-02-18 08:32:06 +01:00
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
2020-04-03 01:08:52 +11:00
|
|
|
private readonly IWebHostEnvironment _env;
|
2020-03-25 18:21:44 +11:00
|
|
|
private readonly IConfiguration _config;
|
2020-03-25 20:42:02 +01:00
|
|
|
|
2020-03-25 18:21:44 +11:00
|
|
|
/// <summary>
|
2020-12-04 13:09:08 +11:00
|
|
|
/// Initializes a new instance of the <see cref="Startup"/> class.
|
2020-03-25 18:21:44 +11:00
|
|
|
/// </summary>
|
2020-08-24 14:23:08 +02:00
|
|
|
/// <param name="webHostEnvironment">The Web Host Environment</param>
|
|
|
|
|
/// <param name="config">The Configuration</param>
|
2020-03-25 18:21:44 +11:00
|
|
|
/// <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)
|
2020-03-25 20:42:02 +01:00
|
|
|
{
|
2020-04-03 01:08:52 +11:00
|
|
|
_env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
|
2020-03-25 18:21:44 +11:00
|
|
|
_config = config ?? throw new ArgumentNullException(nameof(config));
|
2020-03-25 20:42:02 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-08 12:32:19 +01:00
|
|
|
|
2020-12-23 12:02:01 +11:00
|
|
|
|
2020-12-04 13:09:08 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Configures the services
|
|
|
|
|
/// </summary>
|
2020-12-08 12:32:19 +01:00
|
|
|
/// <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)
|
2020-12-23 12:02:01 +11:00
|
|
|
.AddBackOffice()
|
|
|
|
|
.AddWebsite()
|
2020-12-24 18:11:16 +11:00
|
|
|
.AddComposers()
|
2020-10-22 12:23:32 +02:00
|
|
|
.Build();
|
2020-12-04 13:09:08 +11:00
|
|
|
#pragma warning restore IDE0022 // Use expression body for methods
|
2020-12-23 12:02:01 +11:00
|
|
|
|
2020-02-18 08:32:06 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-04 13:09:08 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Configures the application
|
|
|
|
|
/// </summary>
|
2020-04-03 01:08:52 +11:00
|
|
|
public void Configure(IApplicationBuilder app)
|
2020-02-18 08:32:06 +01:00
|
|
|
{
|
2020-04-03 01:08:52 +11:00
|
|
|
if (_env.IsDevelopment())
|
2020-02-18 08:32:06 +01:00
|
|
|
{
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
}
|
2020-05-12 10:21:40 +10:00
|
|
|
|
2020-12-08 16:33:50 +11:00
|
|
|
app.UseUmbracoBackOffice();
|
2020-11-03 18:55:55 +01:00
|
|
|
app.UseUmbracoWebsite();
|
2020-02-18 08:32:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|