From 41444bb292c5f27275d7d0aa277e35ba0451710d Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Sat, 19 Oct 2024 16:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7nuget=E5=8C=85=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4autofac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/IRC.Core.SCP.csproj | 12 ++--- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 14 +++--- .../ServiceCollectionSetup.cs | 49 +++++++++---------- .../IRaCIS.Core.Application.csproj | 12 ++--- .../IRaCIS.Core.Infra.EFCore.csproj | 10 ++-- .../IRaCIS.Core.Infrastructure.csproj | 6 +-- IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 8 +-- 7 files changed, 54 insertions(+), 57 deletions(-) diff --git a/IRC.Core.SCP/IRC.Core.SCP.csproj b/IRC.Core.SCP/IRC.Core.SCP.csproj index 61afafb4e..768c65fef 100644 --- a/IRC.Core.SCP/IRC.Core.SCP.csproj +++ b/IRC.Core.SCP/IRC.Core.SCP.csproj @@ -10,25 +10,25 @@ - - + + - + - + true - + - + diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 1a7f28ec4..34d17bbd7 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -62,25 +62,23 @@ - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - + + + - + diff --git a/IRaCIS.Core.API/_ServiceExtensions/ServiceCollectionSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/ServiceCollectionSetup.cs index 6eb538635..7541ecf25 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/ServiceCollectionSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/ServiceCollectionSetup.cs @@ -1,4 +1,3 @@ -using Autofac; using IP2Region.Net.Abstractions; using IP2Region.Net.XDB; using IRaCIS.Core.Application.BackGroundJob; @@ -96,42 +95,42 @@ public static class ServiceCollectionSetup } #region Autofac 废弃 -public class AutofacModuleSetup : Autofac.Module -{ - protected override void Load(ContainerBuilder containerBuilder) - { +//public class AutofacModuleSetup : Autofac.Module +//{ +// protected override void Load(ContainerBuilder containerBuilder) +// { - #region byzhouhang 20210917 此处注册泛型仓储 可以减少Domain层 和Infra.EFcore 两层 空的仓储接口定义和 仓储文件定义 +// #region byzhouhang 20210917 此处注册泛型仓储 可以减少Domain层 和Infra.EFcore 两层 空的仓储接口定义和 仓储文件定义 - containerBuilder.RegisterGeneric(typeof(Repository<>)) - .As(typeof(IRepository<>)).InstancePerLifetimeScope();//注册泛型仓储 +// containerBuilder.RegisterGeneric(typeof(Repository<>)) +// .As(typeof(IRepository<>)).InstancePerLifetimeScope();//注册泛型仓储 - containerBuilder.RegisterType().As().InstancePerLifetimeScope(); +// containerBuilder.RegisterType().As().InstancePerLifetimeScope(); - #endregion +// #endregion - #region 指定控制器也由autofac 来进行实例获取 https://www.cnblogs.com/xwhqwer/p/15320838.html +// #region 指定控制器也由autofac 来进行实例获取 https://www.cnblogs.com/xwhqwer/p/15320838.html - //获取所有控制器类型并使用属性注入 - containerBuilder.RegisterAssemblyTypes(typeof(BaseService).Assembly) - .Where(type => typeof(IDynamicWebApi).IsAssignableFrom(type)) - .PropertiesAutowired(); +// //获取所有控制器类型并使用属性注入 +// containerBuilder.RegisterAssemblyTypes(typeof(BaseService).Assembly) +// .Where(type => typeof(IDynamicWebApi).IsAssignableFrom(type)) +// .PropertiesAutowired(); - #endregion +// #endregion - Assembly application = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "IRaCIS.Core.Application.dll"); - containerBuilder.RegisterAssemblyTypes(application).Where(t => t.FullName.Contains("Service")) - .PropertiesAutowired().AsImplementedInterfaces(); +// Assembly application = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "IRaCIS.Core.Application.dll"); +// containerBuilder.RegisterAssemblyTypes(application).Where(t => t.FullName.Contains("Service")) +// .PropertiesAutowired().AsImplementedInterfaces(); - //containerBuilder.RegisterType().As().SingleInstance(); - //containerBuilder.RegisterType().As().InstancePerLifetimeScope(); +// //containerBuilder.RegisterType().As().SingleInstance(); +// //containerBuilder.RegisterType().As().InstancePerLifetimeScope(); - //注册hangfire任务 依赖注入 - containerBuilder.RegisterType().As().InstancePerDependency(); +// //注册hangfire任务 依赖注入 +// containerBuilder.RegisterType().As().InstancePerDependency(); - } -} +// } +//} #endregion diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 9c039cd04..99a2cfcf6 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -48,9 +48,9 @@ - + - + @@ -60,13 +60,13 @@ - + - + @@ -74,10 +74,10 @@ - + - + diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index dd8788146..383747676 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -28,14 +28,14 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index a59275bf9..cac011aba 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -12,13 +12,13 @@ - + - + - + diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index 54bd36e5d..ee616207e 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -50,10 +50,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive