NetCore: MSDI refactor remove IFactory & IRegister (#9308)
* Replace IFactory with IServiceProvider * Replace IRegister with IServiceCollection * Fix Rte.cshtml so the view can service locate. * Replace Composing Lifetime with MSDI ServiceLifetime * Remove ServiceProvider AddMultipleUnique extension * Remove Umbraco.Web.Composing.Current.Reset and any calls * Remove LightInject from net framework projects * Brought back a helper for setting MediaFileSystem underlying IFileSystem
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Infrastructure.Composing;
|
||||
using Umbraco.Web.Actions;
|
||||
using Umbraco.Web.ContentApps;
|
||||
using Umbraco.Web.Dashboards;
|
||||
@@ -30,10 +29,11 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public static class WebCompositionExtensions
|
||||
{
|
||||
public static IFactory CreateFactory(this Composition composition)
|
||||
[Obsolete("This extension method exists only to ease migration, please refactor")]
|
||||
public static IServiceProvider CreateServiceProvider(this Composition composition)
|
||||
{
|
||||
composition.RegisterBuilders();
|
||||
return ServiceProviderFactoryAdapter.Wrap(composition.Services.BuildServiceProvider());
|
||||
return composition.Services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
#region Uniques
|
||||
@@ -44,9 +44,9 @@ namespace Umbraco.Web
|
||||
/// <typeparam name="T">The type of the content last chance finder.</typeparam>
|
||||
/// <param name="composition">The composition.</param>
|
||||
public static void SetContentLastChanceFinder<T>(this Composition composition)
|
||||
where T : IContentLastChanceFinder
|
||||
where T : class, IContentLastChanceFinder
|
||||
{
|
||||
composition.RegisterUnique<IContentLastChanceFinder, T>();
|
||||
composition.Services.AddUnique<IContentLastChanceFinder, T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,9 +54,9 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
/// <param name="composition">The composition.</param>
|
||||
/// <param name="factory">A function creating a last chance finder.</param>
|
||||
public static void SetContentLastChanceFinder(this Composition composition, Func<IFactory, IContentLastChanceFinder> factory)
|
||||
public static void SetContentLastChanceFinder(this Composition composition, Func<IServiceProvider, IContentLastChanceFinder> factory)
|
||||
{
|
||||
composition.RegisterUnique(factory);
|
||||
composition.Services.AddUnique(factory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Web
|
||||
/// <param name="finder">A last chance finder.</param>
|
||||
public static void SetContentLastChanceFinder(this Composition composition, IContentLastChanceFinder finder)
|
||||
{
|
||||
composition.RegisterUnique(_ => finder);
|
||||
composition.Services.AddUnique(_ => finder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,9 +75,9 @@ namespace Umbraco.Web
|
||||
/// <typeparam name="T">The type of the site domain helper.</typeparam>
|
||||
/// <param name="composition"></param>
|
||||
public static void SetSiteDomainHelper<T>(this Composition composition)
|
||||
where T : ISiteDomainHelper
|
||||
where T : class, ISiteDomainHelper
|
||||
{
|
||||
composition.RegisterUnique<ISiteDomainHelper, T>();
|
||||
composition.Services.AddUnique<ISiteDomainHelper, T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,9 +85,9 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
/// <param name="composition">The composition.</param>
|
||||
/// <param name="factory">A function creating a helper.</param>
|
||||
public static void SetSiteDomainHelper(this Composition composition, Func<IFactory, ISiteDomainHelper> factory)
|
||||
public static void SetSiteDomainHelper(this Composition composition, Func<IServiceProvider, ISiteDomainHelper> factory)
|
||||
{
|
||||
composition.RegisterUnique(factory);
|
||||
composition.Services.AddUnique(factory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Web
|
||||
/// <param name="helper">A helper.</param>
|
||||
public static void SetSiteDomainHelper(this Composition composition, ISiteDomainHelper helper)
|
||||
{
|
||||
composition.RegisterUnique(_ => helper);
|
||||
composition.Services.AddUnique(_ => helper);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user