wanshenmean
2026-03-11 5af11cc200dd5ebe474b9c0475883b0e6d1e3759
Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/App.cs
@@ -49,7 +49,7 @@
        public static readonly IEnumerable<Type> EffectiveTypes;
        /// <summary>优先使用App.GetService()手动获取服务</summary>
        public static IServiceProvider RootServices => IsRun || IsBuild ? InternalApp.RootServices : null;
        public static IServiceProvider? RootServices => IsRun || IsBuild ? InternalApp.RootServices : null;
        /// <summary>获取Web主机环境,如,是否是开发环境,生产环境等</summary>
        public static IWebHostEnvironment WebHostEnvironment => InternalApp.WebHostEnvironment;
@@ -63,7 +63,7 @@
        /// <summary>
        /// 获取请求上下文
        /// </summary>
        public static HttpContext HttpContext => RootServices?.GetService<IHttpContextAccessor>()?.HttpContext;
        public static HttpContext? HttpContext => RootServices?.GetService<IHttpContextAccessor>()?.HttpContext;
        public static IUser User => GetService<IUser>();
@@ -108,10 +108,10 @@
            return serviceProvider;
        }
        public static TService GetService<TService>(bool mustBuild = true) where TService : class
        public static TService? GetService<TService>(bool mustBuild = true) where TService : class
        {
            TService test = App.GetService(typeof(TService), null, mustBuild) as TService;
            return test;
            object? service = App.GetService(typeof(TService), null, mustBuild);
            return service as TService;
        }
        /// <summary>获取请求生存周期的服务</summary>
@@ -119,7 +119,7 @@
        /// <param name="serviceProvider"></param>
        /// <param name="mustBuild"></param>
        /// <returns></returns>
        public static TService GetService<TService>(IServiceProvider serviceProvider, bool mustBuild = true)
        public static TService? GetService<TService>(IServiceProvider? serviceProvider, bool mustBuild = true)
            where TService : class => (serviceProvider ?? App.GetServiceProvider(typeof(TService), mustBuild, false))?.GetService<TService>();
        /// <summary>获取请求生存周期的服务</summary>
@@ -127,10 +127,10 @@
        /// <param name="serviceProvider"></param>
        /// <param name="mustBuild"></param>
        /// <returns></returns>
        public static object GetService(Type type, IServiceProvider serviceProvider = null, bool mustBuild = true)
        public static object? GetService(Type type, IServiceProvider? serviceProvider = null, bool mustBuild = true)
        {
            IServiceProvider? obj2 = (serviceProvider ?? App.GetServiceProvider(type, mustBuild, false));
            object obj = obj2?.GetService(type);
            object? obj = obj2?.GetService(type);
            return obj;
        }
@@ -177,7 +177,7 @@
        /// <typeparam name="TOptions">强类型选项类</typeparam>
        /// <param name="serviceProvider"></param>
        /// <returns>TOptions</returns>
        public static TOptions GetOptions<TOptions>(IServiceProvider serviceProvider = null) where TOptions : class, new()
        public static TOptions? GetOptions<TOptions>(IServiceProvider? serviceProvider = null) where TOptions : class, new()
        {
            IOptions<TOptions> service = App.GetService<IOptions<TOptions>>(serviceProvider ?? App.RootServices, false);
            return service?.Value;
@@ -187,10 +187,10 @@
        /// <typeparam name="TOptions">强类型选项类</typeparam>
        /// <param name="serviceProvider"></param>
        /// <returns>TOptions</returns>
        public static TOptions GetOptionsMonitor<TOptions>(IServiceProvider serviceProvider = null)
        public static TOptions? GetOptionsMonitor<TOptions>(IServiceProvider? serviceProvider = null)
            where TOptions : class, new()
        {
            IOptionsMonitor<TOptions> service =
            IOptionsMonitor<TOptions>? service =
                App.GetService<IOptionsMonitor<TOptions>>(serviceProvider ?? App.RootServices, false);
            return service?.CurrentValue;
        }
@@ -199,10 +199,10 @@
        /// <typeparam name="TOptions">强类型选项类</typeparam>
        /// <param name="serviceProvider"></param>
        /// <returns>TOptions</returns>
        public static TOptions GetOptionsSnapshot<TOptions>(IServiceProvider serviceProvider = null)
        public static TOptions? GetOptionsSnapshot<TOptions>(IServiceProvider? serviceProvider = null)
            where TOptions : class, new()
        {
            IOptionsSnapshot<TOptions> service = App.GetService<IOptionsSnapshot<TOptions>>(serviceProvider, false);
            IOptionsSnapshot<TOptions>? service = App.GetService<IOptionsSnapshot<TOptions>>(serviceProvider, false);
            return service?.Value;
        }