@@ -4147,7 +4147,6 @@ public static T New<T>(this IContainer container, Made.TypedMade<T> made,
4147
4147
/// <param name="container">Container</param> <param name="serviceType">New service type.</param>
4148
4148
/// <param name="registeredServiceType">Existing registered service type.</param>
4149
4149
/// <param name="serviceKey">(optional)</param> <param name="registeredServiceKey">(optional)</param>
4150
- /// <remarks>Does nothing if registration is already exists.</remarks>
4151
4150
public static void RegisterMapping(this IContainer container, Type serviceType, Type registeredServiceType,
4152
4151
object serviceKey = null, object registeredServiceKey = null) =>
4153
4152
Registrator.RegisterMapping(container,
@@ -4160,7 +4159,6 @@ public static void RegisterMapping(this IContainer container, Type serviceType,
4160
4159
/// <typeparam name="TService">New service type.</typeparam>
4161
4160
/// <typeparam name="TRegisteredService">Existing registered service type.</typeparam>
4162
4161
/// <param name="serviceKey">(optional)</param> <param name="registeredServiceKey">(optional)</param>
4163
- /// <remarks>Does nothing if registration is already exists.</remarks>
4164
4162
public static void RegisterMapping<TService, TRegisteredService>(this IContainer container,
4165
4163
object serviceKey = null, object registeredServiceKey = null) =>
4166
4164
Registrator.RegisterMapping(container,
@@ -7584,11 +7582,11 @@ public static void Unregister<TService>(this IRegistrator registrator,
7584
7582
/// Throw if no such registered service type in container.</summary>
7585
7583
/// <param name="registrator">Registrator</param> <param name="serviceType">New service type.</param>
7586
7584
/// <param name="registeredServiceType">Existing registered service type.</param>
7585
+ /// <param name="ifAlreadyRegistered">The registration to overwrite or preserve the already registered service</param>
7587
7586
/// <param name="serviceKey">(optional)</param> <param name="registeredServiceKey">(optional)</param>
7588
7587
/// <param name="factoryType">(optional) By default is <see cref="FactoryType.Service"/></param>
7589
- /// <remarks>Does nothing if registration is already exists.</remarks>
7590
7588
public static void RegisterMapping(this IRegistrator registrator, Type serviceType, Type registeredServiceType,
7591
- object serviceKey = null, object registeredServiceKey = null, FactoryType factoryType = FactoryType.Service)
7589
+ IfAlreadyRegistered? ifAlreadyRegistered, object serviceKey = null, object registeredServiceKey = null, FactoryType factoryType = FactoryType.Service)
7592
7590
{
7593
7591
var factories = registrator.GetRegisteredFactories(registeredServiceType, registeredServiceKey, factoryType);
7594
7592
@@ -7598,20 +7596,37 @@ public static void RegisterMapping(this IRegistrator registrator, Type serviceTy
7598
7596
if (factories.Length > 1)
7599
7597
Throw.It(Error.RegisterMappingUnableToSelectFromMultipleFactories, serviceType, serviceKey, factories);
7600
7598
7601
- registrator.Register(factories[0], serviceType, serviceKey, IfAlreadyRegistered.Keep , false);
7599
+ registrator.Register(factories[0], serviceType, serviceKey, ifAlreadyRegistered , false);
7602
7600
}
7603
7601
7602
+ /// <summary>Registers new service type with factory for registered service type.
7603
+ /// Throw if no such registered service type in container.</summary>
7604
+ public static void RegisterMapping(this IRegistrator registrator, Type serviceType, Type registeredServiceType,
7605
+ object serviceKey = null, object registeredServiceKey = null, FactoryType factoryType = FactoryType.Service) =>
7606
+ registrator.RegisterMapping(serviceType, registeredServiceType, null, serviceKey, registeredServiceKey, factoryType);
7607
+
7604
7608
/// <summary>Registers new service type with factory for registered service type.
7605
7609
/// Throw if no such registered service type in container.</summary>
7606
7610
/// <param name="registrator">Registrator</param>
7607
7611
/// <typeparam name="TService">New service type.</typeparam>
7608
7612
/// <typeparam name="TRegisteredService">Existing registered service type.</typeparam>
7609
7613
/// <param name="serviceKey">(optional)</param> <param name="registeredServiceKey">(optional)</param>
7610
7614
/// <param name="factoryType">(optional) By default is <see cref="FactoryType.Service"/></param>
7611
- /// <remarks>Does nothing if registration is already exists.</remarks>
7612
7615
public static void RegisterMapping<TService, TRegisteredService>(this IRegistrator registrator,
7613
7616
object serviceKey = null, object registeredServiceKey = null, FactoryType factoryType = FactoryType.Service) =>
7614
- registrator.RegisterMapping(typeof(TService), typeof(TRegisteredService), serviceKey, registeredServiceKey);
7617
+ registrator.RegisterMapping(typeof(TService), typeof(TRegisteredService), null, serviceKey, registeredServiceKey);
7618
+
7619
+ /// <summary>Registers new service type with factory for registered service type.
7620
+ /// Throw if no such registered service type in container.</summary>
7621
+ /// <param name="container">Container</param>
7622
+ /// <typeparam name="TService">New service type.</typeparam>
7623
+ /// <typeparam name="TRegisteredService">Existing registered service type.</typeparam>
7624
+ /// <param name="ifAlreadyRegistered">The registration to overwrite or preserve the already registered service</param>
7625
+ /// <param name="serviceKey">(optional)</param> <param name="registeredServiceKey">(optional)</param>
7626
+ public static void RegisterMapping<TService, TRegisteredService>(this IContainer container,
7627
+ IfAlreadyRegistered ifAlreadyRegistered, object serviceKey = null, object registeredServiceKey = null) =>
7628
+ Registrator.RegisterMapping(container,
7629
+ typeof(TService), typeof(TRegisteredService), ifAlreadyRegistered, serviceKey, registeredServiceKey);
7615
7630
7616
7631
/// <summary>Register a service without implementation which can be provided later in terms
7617
7632
/// of normal registration with IfAlreadyRegistered.Replace parameter.
0 commit comments