diff --git a/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs b/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs
index 6c806ce0db..d0f198557f 100644
--- a/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs
+++ b/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs
@@ -37,6 +37,19 @@ namespace Umbraco.Extensions
services.Add(ServiceDescriptor.Describe(typeof(TService), typeof(TImplementing), lifetime));
}
+ ///
+ /// Adds services of types & with a shared implementation type of to the specified .
+ ///
+ ///
+ /// Removes all previous registrations for the types & .
+ ///
+ public static void AddMultipleUnique(
+ this IServiceCollection services)
+ where TService1 : class
+ where TService2 : class
+ where TImplementing : class, TService1, TService2
+ => services.AddMultipleUnique(ServiceLifetime.Singleton);
+
///
/// Adds services of types & with a shared implementation type of to the specified .
///
@@ -45,7 +58,7 @@ namespace Umbraco.Extensions
///
public static void AddMultipleUnique(
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();
}
+ ///
+ /// Adds a service of type with an implementation factory method to the specified .
+ ///
+ ///
+ /// Removes all previous registrations for the type .
+ ///
+ public static void AddUnique(
+ this IServiceCollection services,
+ Func factory)
+ where TService : class
+ => services.AddUnique(factory, ServiceLifetime.Singleton);
+
///
/// Adds a service of type with an implementation factory method to the specified .
///
@@ -72,7 +97,7 @@ namespace Umbraco.Extensions
public static void AddUnique(
this IServiceCollection services,
Func factory,
- ServiceLifetime lifetime = ServiceLifetime.Singleton)
+ ServiceLifetime lifetime)
where TService : class
{
services.RemoveAll();