35 lines
967 B
C#
35 lines
967 B
C#
namespace CloudGaming.Core.FreeRedis;
|
|
|
|
/// <summary>
|
|
/// redis 启动器
|
|
/// </summary>
|
|
public class CoreFreeRedisStartup : StartupModule<CoreFreeRedisStartup>
|
|
{
|
|
/// <summary>
|
|
/// 配置服务
|
|
/// </summary>
|
|
/// <param name="webApplicationBuilder"></param>
|
|
public override void ConfigureServices(WebApplicationBuilder webApplicationBuilder)
|
|
{
|
|
var connectionString = webApplicationBuilder.Configuration["ConnectionStrings:Redis"];
|
|
|
|
if (string.IsNullOrWhiteSpace(connectionString))
|
|
{
|
|
throw new ArgumentNullException("ConnectionStrings:Redis 配置信息读取失败!");
|
|
}
|
|
|
|
webApplicationBuilder.Services.AddSingleton(typeof(RedisClient), serviceProvider => new RedisClient(connectionString));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 启动服务
|
|
/// </summary>
|
|
/// <param name="webApplication"></param>
|
|
public override void Configure(WebApplication webApplication)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|