From 3ec3e0c1913bc902dbbcaeae2959897df6212ec2 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期四, 28 十一月 2024 15:41:23 +0800
Subject: [PATCH] 更新
---
WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs | 60 ++++++++----------------------------------------------------
1 files changed, 8 insertions(+), 52 deletions(-)
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs
index b4c0368..8d19d8e 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs
@@ -12,68 +12,22 @@
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.LogHelper;
namespace WIDESEAWCS_Core.Extensions
{
public class AutofacModuleRegister : Autofac.Module
{
- //private static readonly ILog log = LogManager.GetLogger(typeof(AutofacModuleRegister));
protected override void Load(ContainerBuilder builder)
{
- //var basePath = AppContext.BaseDirectory;
-
- //var cacheType = new List<Type>();
-
- //builder.RegisterType<LogAOP>();
- //cacheType.Add(typeof(LogAOP));
-
- //builder.RegisterGeneric(typeof(RepositoryBase<>)).As(typeof(IRepository<>)).InstancePerDependency();//娉ㄥ唽浠撳偍
- //builder.RegisterGeneric(typeof(ServiceBase<,>)).As(typeof(IService<>)).InstancePerDependency();//娉ㄥ唽鏈嶅姟
-
- //Type baseType = typeof(IDependency);
-
- //List<RuntimeLibrary> compilationLibrary = DependencyContext.Default
- // .RuntimeLibraries
- // .Where(x => !x.Serviceable
- // && x.Type == "project" && ((x.Name.EndsWith("Repository")) || (x.Name.EndsWith("Service"))))
- // .ToList();
- //List<Assembly> assemblyList = new List<Assembly>();
- //foreach (var library in compilationLibrary)
- //{
- // try
- // {
- // string path = Path.Combine(basePath, $"{library.Name}.dll");
- // if (!File.Exists(path))
- // {
- // var msg = $"{library.Name}.dll涓㈠け锛屽洜涓洪」鐩В鑰︿簡锛屾墍浠ラ渶瑕佸厛F6缂栬瘧锛屽啀F5杩愯锛岃妫�鏌� bin 鏂囦欢澶癸紝骞舵嫹璐濄��";
- // //log.Error(msg);
- // throw new Exception(msg);
- // }
- // assemblyList.Add(Assembly.LoadFrom(path));
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine(library.Name + ex.Message);
- // }
- //}
- //builder.RegisterAssemblyTypes(assemblyList.ToArray())
- // .Where(x => !x.IsAbstract /*&& baseType.IsAssignableFrom(x)*/)
- // .AsImplementedInterfaces()
- // .PropertiesAutowired()
- // .InstancePerDependency()
- // .EnableInterfaceInterceptors()
- // .InterceptedBy(cacheType.ToArray());
-
- //builder.RegisterType<UnitOfWorkManage>().As<IUnitOfWorkManage>()
- // .AsImplementedInterfaces()
- // .InstancePerLifetimeScope()
- // .PropertiesAutowired();
-
var basePath = AppContext.BaseDirectory;
var cacheType = new List<Type>();
- builder.RegisterType<LogAOP>();
- cacheType.Add(typeof(LogAOP));
+ if (AppSettings.Get(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
+ {
+ builder.RegisterType<LogAOP>();
+ cacheType.Add(typeof(LogAOP));
+ }
builder.RegisterGeneric(typeof(RepositoryBase<>)).As(typeof(IRepository<>)).InstancePerDependency();//娉ㄥ唽浠撳偍
builder.RegisterGeneric(typeof(ServiceBase<,>)).As(typeof(IService<>)).InstancePerDependency();//娉ㄥ唽鏈嶅姟
@@ -116,6 +70,8 @@
.AsImplementedInterfaces()
.InstancePerLifetimeScope()
.PropertiesAutowired();
+
+ builder.RegisterType<RequestLogModel>().InstancePerLifetimeScope();
}
}
}
--
Gitblit v1.9.3