升级.net8暂存

This commit is contained in:
dell
2024-11-14 09:01:37 +08:00
parent 08a59bd2a3
commit 48e9e27fa0
110 changed files with 11291 additions and 4541 deletions

View File

@ -32,14 +32,14 @@ namespace HT.Cloud.Code
public static SystemConfig SystemConfig { get; set; }
/// <summary>
/// 获取请求生存周期的服务(未注册返回null)
/// </summary>
/// <typeparam name="TService"></typeparam>
/// <param name="serviceProvider"></param>
/// <returns></returns>
public static TService GetService<TService>(IServiceProvider serviceProvider = null) where TService : class
{
/// <summary>
/// 获取请求生存周期的服务(未注册返回null)
/// </summary>
/// <typeparam name="TService"></typeparam>
/// <param name="serviceProvider"></param>
/// <returns></returns>
public static TService GetService<TService>(IServiceProvider serviceProvider = null) where TService : class
{
return GetService(typeof(TService), serviceProvider) as TService;
}
@ -95,13 +95,22 @@ namespace HT.Cloud.Code
{
return HttpContext.RequestServices;
}
return RootServices;
}
/// <summary>
/// 获取版本号
/// </summary>
/// <returns></returns>
public static string GetVersion()
else if (RootServices != null)
{
using var scoped = RootServices.CreateScope();
return scoped.ServiceProvider;
}
else
{
using var serviceProvider = Services.BuildServiceProvider();
return serviceProvider;
}
}
/// <summary>
/// 获取版本号
/// </summary>
/// <returns></returns>
public static string GetVersion()
{
Version version = Assembly.GetEntryAssembly().GetName().Version;
return version.ToString();
@ -138,5 +147,5 @@ namespace HT.Cloud.Code
context.Context.Response.Headers.Add("Cache-Control", new[] { "public,max-age=" + second });
context.Context.Response.Headers.Add("Expires", new[] { DateTime.UtcNow.AddYears(1).ToString("R") }); // Format RFC1123
}
}
}
}