liaoxujun@qq.com
2024-03-05 f0ca9fb79a91544c037c55a291be00e8c469bf34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Autofac;
using Microsoft.Extensions.Configuration;
 
namespace CoreCms.Net.Utility
{
 
    public static class Storage
    {
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static Storage()
        {
            //var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
            //    .AddJsonFile("appsettings.json", true, true);
            //Configuration = builder.Build();
 
            //Assemblys = DependencyContext.Default.CompileLibraries
            //    .Where(x => x.Type == "project")
            //    .Select(x => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(x.Name)))
            //    .ToList();
        }
 
 
 
        /// <summary>
        /// 配置文件的根节点
        /// </summary>
        public static IConfigurationRoot Configuration { get; }
 
        /// <summary>
        /// 全局程序集
        /// </summary>
        //public static List<Assembly> Assemblys { get; }
 
 
        /// <summary>
        /// Autofac依赖注入静态服务
        /// </summary>
        public static ILifetimeScope Container;
 
        /// <summary>
        /// 获取服务(Single)
        /// </summary>
        /// <typeparam name="T">接口类型</typeparam>
        /// <returns></returns>
        public static T GetService<T>() where T : class
        {
            return Container.Resolve<T>();
        }
 
 
    }
 
}