Reduce the usage of BuildServiceProvider

This commit is contained in:
Shannon
2020-03-25 18:21:44 +11:00
parent 1a8f422dce
commit a5d728cc51
3 changed files with 45 additions and 28 deletions

View File

@@ -16,13 +16,29 @@ namespace Umbraco.Web.UI.BackOffice
{
public class Startup
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IConfiguration _config;
/// <summary>
/// Constructor
/// </summary>
/// <param name="webHostEnvironment"></param>
/// <param name="config"></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)
{
_webHostEnvironment = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
_config = config ?? throw new ArgumentNullException(nameof(config));
}
// 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
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbracoConfiguration();
services.AddUmbracoCore();
services.AddUmbracoConfiguration(_config);
services.AddUmbracoCore(_webHostEnvironment);
services.AddUmbracoWebsite();
}