Don't use default params for AddUnique extension methods (breaks v9) (#12485)
(cherry picked from commit f3c4c677f3)
This commit is contained in:
committed by
Paul Johnson
parent
c5e1f5c67d
commit
adcc9a0e1f
@@ -37,6 +37,19 @@ namespace Umbraco.Extensions
|
||||
services.Add(ServiceDescriptor.Describe(typeof(TService), typeof(TImplementing), lifetime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds services of types <typeparamref name="TService1"/> & <typeparamref name="TService2"/> with a shared implementation type of <typeparamref name="TImplementing"/> to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Removes all previous registrations for the types <typeparamref name="TService1"/> & <typeparamref name="TService2"/>.
|
||||
/// </remarks>
|
||||
public static void AddMultipleUnique<TService1, TService2, TImplementing>(
|
||||
this IServiceCollection services)
|
||||
where TService1 : class
|
||||
where TService2 : class
|
||||
where TImplementing : class, TService1, TService2
|
||||
=> services.AddMultipleUnique<TService1, TService2, TImplementing>(ServiceLifetime.Singleton);
|
||||
|
||||
/// <summary>
|
||||
/// Adds services of types <typeparamref name="TService1"/> & <typeparamref name="TService2"/> with a shared implementation type of <typeparamref name="TImplementing"/> to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
@@ -45,7 +58,7 @@ namespace Umbraco.Extensions
|
||||
/// </remarks>
|
||||
public static void AddMultipleUnique<TService1, TService2, TImplementing>(
|
||||
this IServiceCollection services,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Singleton)
|
||||
ServiceLifetime lifetime)
|
||||
where TService1 : class
|
||||
where TService2 : class
|
||||
where TImplementing : class, TService1, TService2
|
||||
@@ -63,6 +76,18 @@ namespace Umbraco.Extensions
|
||||
services.AddSingleton<TImplementing>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a service of type <typeparamref name="TService"/> with an implementation factory method to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Removes all previous registrations for the type <typeparamref name="TService"/>.
|
||||
/// </remarks>
|
||||
public static void AddUnique<TService>(
|
||||
this IServiceCollection services,
|
||||
Func<IServiceProvider, TService> factory)
|
||||
where TService : class
|
||||
=> services.AddUnique(factory, ServiceLifetime.Singleton);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a service of type <typeparamref name="TService"/> with an implementation factory method to the specified <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
@@ -72,7 +97,7 @@ namespace Umbraco.Extensions
|
||||
public static void AddUnique<TService>(
|
||||
this IServiceCollection services,
|
||||
Func<IServiceProvider, TService> factory,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Singleton)
|
||||
ServiceLifetime lifetime)
|
||||
where TService : class
|
||||
{
|
||||
services.RemoveAll<TService>();
|
||||
|
||||
Reference in New Issue
Block a user