diff --git a/Source/Euonia.Mapping.Automapper/AutomapperModule.cs b/Source/Euonia.Mapping.Automapper/AutomapperModule.cs index b635f69..e1de911 100644 --- a/Source/Euonia.Mapping.Automapper/AutomapperModule.cs +++ b/Source/Euonia.Mapping.Automapper/AutomapperModule.cs @@ -8,20 +8,22 @@ namespace Nerosoft.Euonia.Mapping; /// public class AutomapperModule : ModuleContextBase { + private const string SERVICE_INJECTION_KEY = "automapper"; + /// public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAutomapper(); - context.Services.AddSingleton(); - } + { + context.Services.AddAutomapper(); + context.Services.AddKeyedSingleton(SERVICE_INJECTION_KEY); + } /// public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - var factory = context.ServiceProvider.GetService(); - if (factory != null) - { - TypeAdapterFactory.SetCurrent(factory); - } - } + { + var factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); + if (factory != null) + { + TypeAdapterFactory.SetCurrent(factory); + } + } } \ No newline at end of file diff --git a/Source/Euonia.Mapping.Mapster/MapsterModule.cs b/Source/Euonia.Mapping.Mapster/MapsterModule.cs index 497ee1c..4f9061a 100644 --- a/Source/Euonia.Mapping.Mapster/MapsterModule.cs +++ b/Source/Euonia.Mapping.Mapster/MapsterModule.cs @@ -8,20 +8,22 @@ namespace Nerosoft.Euonia.Mapping; /// public class MapsterModule : ModuleContextBase { + private const string SERVICE_INJECTION_KEY = "mapster"; + /// public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddMapster(); - context.Services.AddSingleton(); - } + { + context.Services.AddMapster(); + context.Services.AddKeyedSingleton(SERVICE_INJECTION_KEY); + } /// public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - var factory = context.ServiceProvider.GetService(); - if (factory != null) - { - TypeAdapterFactory.SetCurrent(factory); - } - } + { + var factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); + if (factory != null) + { + TypeAdapterFactory.SetCurrent(factory); + } + } } \ No newline at end of file diff --git a/Source/Euonia.Validation/ValidationModule.cs b/Source/Euonia.Validation/ValidationModule.cs index f159e5c..5a228fd 100644 --- a/Source/Euonia.Validation/ValidationModule.cs +++ b/Source/Euonia.Validation/ValidationModule.cs @@ -16,4 +16,14 @@ public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddAutomaticRegistrar(new ValidationRegistrar()); context.Services.AddSingleton(); } + + /// + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var factory = context.ServiceProvider.GetService(); + if (factory != null) + { + ValidatorFactory.SetCurrent(factory); + } + } } \ No newline at end of file diff --git a/project.props b/project.props index d16b777..1a24835 100644 --- a/project.props +++ b/project.props @@ -1,6 +1,6 @@ - 8.1.8 + 8.1.9 damon Nerosoft Ltd. Euonia