hutongqing
2024-08-28 d0f01f571918ae942349068776fa7fb70f3ab5cd
WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/AutofacModuleRegister.cs
@@ -17,58 +17,8 @@
{
    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>();