using Microsoft.AspNetCore.Identity;
using MyCompanyName.MyProjectName.MyModuleName;
#pragma warning disable CS0618 // Type or member is obsolete
namespace Microsoft.Extensions.DependencyInjection;
public static class ServiceCollectionExtensions
{
///
/// 注册Redis缓存
///
public static IServiceCollection AddAbpProRedis(this IServiceCollection service)
{
service.Configure(options => { options.KeyPrefix = "AbpPro:"; });
var configuration = service.GetConfiguration();
var redis = ConnectionMultiplexer.Connect(configuration.GetValue("Redis:Configuration"));
service
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "AbpPro-Protection-Keys");
return service;
}
///
/// 配置虚拟文件系统
///
public static IServiceCollection AddAbpProVirtualFileSystem(this IServiceCollection service)
{
service.Configure(options =>
{
options.FileSets.AddEmbedded();
});
return service;
}
public static IServiceCollection AddAbpProDbContext(this IServiceCollection service)
{
service.Configure(options => { options.UseNpgsql(builder => { builder.TranslateParameterizedCollectionsToConstants(); }); });
return service;
}
}