reduces code duplication
This commit is contained in:
@@ -17,12 +17,18 @@ namespace Umbraco.Core.Composing
|
||||
_container = new LightInjectContainer(container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an ASP.NET Core compatible service container
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ServiceContainer CreateServiceContainer() => new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
|
||||
/// <summary>
|
||||
/// Default ctor for use in Host Builder configuration
|
||||
/// </summary>
|
||||
public UmbracoServiceProviderFactory()
|
||||
{
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = CreateServiceContainer();
|
||||
UmbracoContainer = _container = new LightInjectContainer(container);
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using LightInject;
|
||||
using LightInject.Microsoft.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Integration
|
||||
var msdiServiceProvider = services.BuildServiceProvider();
|
||||
|
||||
// LightInject / Umbraco
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
var serviceProviderFactory = new UmbracoServiceProviderFactory(container);
|
||||
var umbracoContainer = serviceProviderFactory.GetContainer();
|
||||
serviceProviderFactory.CreateBuilder(services); // called during Host Builder, needed to capture services
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Tests.Integration
|
||||
public void BootCoreRuntime()
|
||||
{
|
||||
// LightInject / Umbraco
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
var serviceProviderFactory = new UmbracoServiceProviderFactory(container);
|
||||
var umbracoContainer = serviceProviderFactory.GetContainer();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Tests.Integration
|
||||
services.AddSingleton<IHostApplicationLifetime>(x => Mock.Of<IHostApplicationLifetime>());
|
||||
|
||||
// LightInject / Umbraco
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
var serviceProviderFactory = new UmbracoServiceProviderFactory(container);
|
||||
var umbracoContainer = serviceProviderFactory.GetContainer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user