From 792a336f8c344c7f2de00b12db87dcc202b9cd7f Mon Sep 17 00:00:00 2001 From: damon Date: Wed, 13 Dec 2023 20:39:31 +0800 Subject: [PATCH] Do not use keyed service injection on framework < 8.0 --- Euonia.sln | 1 + .../Euonia.Application.csproj | 1 + .../Euonia.Bus.ActiveMq.csproj | 1 + .../Euonia.Bus.InMemory.csproj | 1 + .../Euonia.Bus.RabbitMq.csproj | 1 + Source/Euonia.Bus/Euonia.Bus.csproj | 1 + Source/Euonia.Business/Euonia.Business.csproj | 1 + .../Euonia.Caching.Memory.csproj | 1 + .../Euonia.Caching.Redis.csproj | 1 + .../Euonia.Caching.Runtime.csproj | 1 + Source/Euonia.Caching/Euonia.Caching.csproj | 1 + Source/Euonia.Core/Euonia.Core.csproj | 1 + Source/Euonia.Domain/Euonia.Domain.csproj | 1 + Source/Euonia.Grpc/Euonia.Grpc.csproj | 1 + Source/Euonia.Hosting/Euonia.Hosting.csproj | 1 + Source/Euonia.Linq/Euonia.Linq.csproj | 1 + .../AutomapperModule.cs | 11 +++++++- .../Euonia.Mapping.Automapper.csproj | 1 + .../Euonia.Mapping.Mapster.csproj | 1 + .../Euonia.Mapping.Mapster/MapsterModule.cs | 11 +++++++- Source/Euonia.Mapping/Euonia.Mapping.csproj | 1 + .../Euonia.Modularity.csproj | 1 + Source/Euonia.Pipeline/Euonia.Pipeline.csproj | 1 + Source/Euonia.Quartz/Euonia.Quartz.csproj | 1 + .../Euonia.Repository.EfCore.csproj | 1 + .../Euonia.Repository.Mongo.csproj | 1 + .../Euonia.Repository.csproj | 1 + .../Euonia.Threading.Azure.csproj | 1 + .../Euonia.Threading.FileSystem.csproj | 1 + .../Euonia.Threading.Redis.csproj | 1 + .../Euonia.Threading.ZooKeeper.csproj | 1 + .../Euonia.Threading/Euonia.Threading.csproj | 1 + .../Euonia.Validation.csproj | 1 + Source/common.props | 22 +--------------- Source/resource.props | 25 +++++++++++++++++++ project.props | 2 +- 36 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 Source/resource.props diff --git a/Euonia.sln b/Euonia.sln index 9d017a5..b2f7e45 100644 --- a/Euonia.sln +++ b/Euonia.sln @@ -21,6 +21,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{E57A56F3-7BAB-4DB5-9CE8-EC91985A6586}" ProjectSection(SolutionItems) = preProject Source\common.props = Source\common.props + Source\resource.props = Source\resource.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bus", "Bus", "{273D1F47-F6AF-4ED5-AAB5-977BD9906B2E}" diff --git a/Source/Euonia.Application/Euonia.Application.csproj b/Source/Euonia.Application/Euonia.Application.csproj index 2f6db60..b973da8 100644 --- a/Source/Euonia.Application/Euonia.Application.csproj +++ b/Source/Euonia.Application/Euonia.Application.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Bus.ActiveMq/Euonia.Bus.ActiveMq.csproj b/Source/Euonia.Bus.ActiveMq/Euonia.Bus.ActiveMq.csproj index 4372568..9656a73 100644 --- a/Source/Euonia.Bus.ActiveMq/Euonia.Bus.ActiveMq.csproj +++ b/Source/Euonia.Bus.ActiveMq/Euonia.Bus.ActiveMq.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Bus.InMemory/Euonia.Bus.InMemory.csproj b/Source/Euonia.Bus.InMemory/Euonia.Bus.InMemory.csproj index c1a67a9..140a23e 100644 --- a/Source/Euonia.Bus.InMemory/Euonia.Bus.InMemory.csproj +++ b/Source/Euonia.Bus.InMemory/Euonia.Bus.InMemory.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Bus.RabbitMq/Euonia.Bus.RabbitMq.csproj b/Source/Euonia.Bus.RabbitMq/Euonia.Bus.RabbitMq.csproj index ba9d082..7aa508f 100644 --- a/Source/Euonia.Bus.RabbitMq/Euonia.Bus.RabbitMq.csproj +++ b/Source/Euonia.Bus.RabbitMq/Euonia.Bus.RabbitMq.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Bus/Euonia.Bus.csproj b/Source/Euonia.Bus/Euonia.Bus.csproj index f760623..dd7b978 100644 --- a/Source/Euonia.Bus/Euonia.Bus.csproj +++ b/Source/Euonia.Bus/Euonia.Bus.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Business/Euonia.Business.csproj b/Source/Euonia.Business/Euonia.Business.csproj index 9247965..4014aaa 100644 --- a/Source/Euonia.Business/Euonia.Business.csproj +++ b/Source/Euonia.Business/Euonia.Business.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Caching.Memory/Euonia.Caching.Memory.csproj b/Source/Euonia.Caching.Memory/Euonia.Caching.Memory.csproj index a251322..abb5727 100644 --- a/Source/Euonia.Caching.Memory/Euonia.Caching.Memory.csproj +++ b/Source/Euonia.Caching.Memory/Euonia.Caching.Memory.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Caching.Redis/Euonia.Caching.Redis.csproj b/Source/Euonia.Caching.Redis/Euonia.Caching.Redis.csproj index 1741819..e15780d 100644 --- a/Source/Euonia.Caching.Redis/Euonia.Caching.Redis.csproj +++ b/Source/Euonia.Caching.Redis/Euonia.Caching.Redis.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Caching.Runtime/Euonia.Caching.Runtime.csproj b/Source/Euonia.Caching.Runtime/Euonia.Caching.Runtime.csproj index 0ffe9fb..cb10141 100644 --- a/Source/Euonia.Caching.Runtime/Euonia.Caching.Runtime.csproj +++ b/Source/Euonia.Caching.Runtime/Euonia.Caching.Runtime.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Caching/Euonia.Caching.csproj b/Source/Euonia.Caching/Euonia.Caching.csproj index 0e511f3..a422211 100644 --- a/Source/Euonia.Caching/Euonia.Caching.csproj +++ b/Source/Euonia.Caching/Euonia.Caching.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Core/Euonia.Core.csproj b/Source/Euonia.Core/Euonia.Core.csproj index d8b40da..dc889a2 100644 --- a/Source/Euonia.Core/Euonia.Core.csproj +++ b/Source/Euonia.Core/Euonia.Core.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Domain/Euonia.Domain.csproj b/Source/Euonia.Domain/Euonia.Domain.csproj index e500e63..955d6be 100644 --- a/Source/Euonia.Domain/Euonia.Domain.csproj +++ b/Source/Euonia.Domain/Euonia.Domain.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Grpc/Euonia.Grpc.csproj b/Source/Euonia.Grpc/Euonia.Grpc.csproj index a198b85..e0c1cfe 100644 --- a/Source/Euonia.Grpc/Euonia.Grpc.csproj +++ b/Source/Euonia.Grpc/Euonia.Grpc.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Hosting/Euonia.Hosting.csproj b/Source/Euonia.Hosting/Euonia.Hosting.csproj index 611a5f6..79b8cbf 100644 --- a/Source/Euonia.Hosting/Euonia.Hosting.csproj +++ b/Source/Euonia.Hosting/Euonia.Hosting.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Linq/Euonia.Linq.csproj b/Source/Euonia.Linq/Euonia.Linq.csproj index a32c8e2..ee0556d 100644 --- a/Source/Euonia.Linq/Euonia.Linq.csproj +++ b/Source/Euonia.Linq/Euonia.Linq.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Mapping.Automapper/AutomapperModule.cs b/Source/Euonia.Mapping.Automapper/AutomapperModule.cs index e1de911..9b6d1c3 100644 --- a/Source/Euonia.Mapping.Automapper/AutomapperModule.cs +++ b/Source/Euonia.Mapping.Automapper/AutomapperModule.cs @@ -14,13 +14,22 @@ public class AutomapperModule : ModuleContextBase public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutomapper(); +#if NET8_0_OR_GREATER context.Services.AddKeyedSingleton(SERVICE_INJECTION_KEY); +#else + context.Services.AddSingleton(); +#endif } /// public override void OnApplicationInitialization(ApplicationInitializationContext context) { - var factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); + ITypeAdapterFactory factory; +#if NET8_0_OR_GREATER + factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); +#else + factory = context.ServiceProvider.GetService(); +#endif if (factory != null) { TypeAdapterFactory.SetCurrent(factory); diff --git a/Source/Euonia.Mapping.Automapper/Euonia.Mapping.Automapper.csproj b/Source/Euonia.Mapping.Automapper/Euonia.Mapping.Automapper.csproj index 22655be..a7bb56a 100644 --- a/Source/Euonia.Mapping.Automapper/Euonia.Mapping.Automapper.csproj +++ b/Source/Euonia.Mapping.Automapper/Euonia.Mapping.Automapper.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Mapping.Mapster/Euonia.Mapping.Mapster.csproj b/Source/Euonia.Mapping.Mapster/Euonia.Mapping.Mapster.csproj index 594d644..4d1db09 100644 --- a/Source/Euonia.Mapping.Mapster/Euonia.Mapping.Mapster.csproj +++ b/Source/Euonia.Mapping.Mapster/Euonia.Mapping.Mapster.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Mapping.Mapster/MapsterModule.cs b/Source/Euonia.Mapping.Mapster/MapsterModule.cs index 4f9061a..c10b416 100644 --- a/Source/Euonia.Mapping.Mapster/MapsterModule.cs +++ b/Source/Euonia.Mapping.Mapster/MapsterModule.cs @@ -14,13 +14,22 @@ public class MapsterModule : ModuleContextBase public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddMapster(); +#if NET8_0_OR_GREATER context.Services.AddKeyedSingleton(SERVICE_INJECTION_KEY); +#else + context.Services.AddSingleton(); +#endif } /// public override void OnApplicationInitialization(ApplicationInitializationContext context) { - var factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); + ITypeAdapterFactory factory; +#if NET8_0_OR_GREATER + factory = context.ServiceProvider.GetKeyedService(SERVICE_INJECTION_KEY); +#else + factory = context.ServiceProvider.GetService(); +#endif if (factory != null) { TypeAdapterFactory.SetCurrent(factory); diff --git a/Source/Euonia.Mapping/Euonia.Mapping.csproj b/Source/Euonia.Mapping/Euonia.Mapping.csproj index 65ed485..4d0d3ea 100644 --- a/Source/Euonia.Mapping/Euonia.Mapping.csproj +++ b/Source/Euonia.Mapping/Euonia.Mapping.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Modularity/Euonia.Modularity.csproj b/Source/Euonia.Modularity/Euonia.Modularity.csproj index abed817..bdbac2a 100644 --- a/Source/Euonia.Modularity/Euonia.Modularity.csproj +++ b/Source/Euonia.Modularity/Euonia.Modularity.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Pipeline/Euonia.Pipeline.csproj b/Source/Euonia.Pipeline/Euonia.Pipeline.csproj index e95dfcb..0706ecc 100644 --- a/Source/Euonia.Pipeline/Euonia.Pipeline.csproj +++ b/Source/Euonia.Pipeline/Euonia.Pipeline.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Quartz/Euonia.Quartz.csproj b/Source/Euonia.Quartz/Euonia.Quartz.csproj index c8164ab..19cf49f 100644 --- a/Source/Euonia.Quartz/Euonia.Quartz.csproj +++ b/Source/Euonia.Quartz/Euonia.Quartz.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Repository.EfCore/Euonia.Repository.EfCore.csproj b/Source/Euonia.Repository.EfCore/Euonia.Repository.EfCore.csproj index e68802f..44abe11 100644 --- a/Source/Euonia.Repository.EfCore/Euonia.Repository.EfCore.csproj +++ b/Source/Euonia.Repository.EfCore/Euonia.Repository.EfCore.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Repository.Mongo/Euonia.Repository.Mongo.csproj b/Source/Euonia.Repository.Mongo/Euonia.Repository.Mongo.csproj index 7d5e4aa..5a8cff6 100644 --- a/Source/Euonia.Repository.Mongo/Euonia.Repository.Mongo.csproj +++ b/Source/Euonia.Repository.Mongo/Euonia.Repository.Mongo.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Repository/Euonia.Repository.csproj b/Source/Euonia.Repository/Euonia.Repository.csproj index 3814292..bdbea1a 100644 --- a/Source/Euonia.Repository/Euonia.Repository.csproj +++ b/Source/Euonia.Repository/Euonia.Repository.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Threading.Azure/Euonia.Threading.Azure.csproj b/Source/Euonia.Threading.Azure/Euonia.Threading.Azure.csproj index cd7fa8e..a197cf9 100644 --- a/Source/Euonia.Threading.Azure/Euonia.Threading.Azure.csproj +++ b/Source/Euonia.Threading.Azure/Euonia.Threading.Azure.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Threading.FileSystem/Euonia.Threading.FileSystem.csproj b/Source/Euonia.Threading.FileSystem/Euonia.Threading.FileSystem.csproj index a86f586..675bf52 100644 --- a/Source/Euonia.Threading.FileSystem/Euonia.Threading.FileSystem.csproj +++ b/Source/Euonia.Threading.FileSystem/Euonia.Threading.FileSystem.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Threading.Redis/Euonia.Threading.Redis.csproj b/Source/Euonia.Threading.Redis/Euonia.Threading.Redis.csproj index 25236b9..af2668c 100644 --- a/Source/Euonia.Threading.Redis/Euonia.Threading.Redis.csproj +++ b/Source/Euonia.Threading.Redis/Euonia.Threading.Redis.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Threading.ZooKeeper/Euonia.Threading.ZooKeeper.csproj b/Source/Euonia.Threading.ZooKeeper/Euonia.Threading.ZooKeeper.csproj index 0ae8732..d176042 100644 --- a/Source/Euonia.Threading.ZooKeeper/Euonia.Threading.ZooKeeper.csproj +++ b/Source/Euonia.Threading.ZooKeeper/Euonia.Threading.ZooKeeper.csproj @@ -1,6 +1,7 @@ + disable diff --git a/Source/Euonia.Threading/Euonia.Threading.csproj b/Source/Euonia.Threading/Euonia.Threading.csproj index a32c8e2..ee0556d 100644 --- a/Source/Euonia.Threading/Euonia.Threading.csproj +++ b/Source/Euonia.Threading/Euonia.Threading.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/Euonia.Validation/Euonia.Validation.csproj b/Source/Euonia.Validation/Euonia.Validation.csproj index f6f8579..2e8d639 100644 --- a/Source/Euonia.Validation/Euonia.Validation.csproj +++ b/Source/Euonia.Validation/Euonia.Validation.csproj @@ -1,6 +1,7 @@ + netstandard2.1;$(TargetFrameworks) diff --git a/Source/common.props b/Source/common.props index d06fd8d..4aa445f 100644 --- a/Source/common.props +++ b/Source/common.props @@ -40,26 +40,6 @@ - - - - - - - - - - - - - + diff --git a/Source/resource.props b/Source/resource.props new file mode 100644 index 0000000..c0bacdf --- /dev/null +++ b/Source/resource.props @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project.props b/project.props index 1a24835..e5a3b28 100644 --- a/project.props +++ b/project.props @@ -1,6 +1,6 @@ - 8.1.9 + 8.1.10 damon Nerosoft Ltd. Euonia