예제 #1
0
 public static HuskyServiceHub AddMailSender <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, IMailDbContext
 {
     husky.Services.AddDbContext <IMailDbContext, TDbContext>();
     husky.Services.AddScoped <IMailSender, MailSender>();
     return(husky);
 }
예제 #2
0
 public static HuskyServiceHub AddDiagnostics <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, IDiagnosticsDbContext
 {
     husky.Services.AddDbContext <IDiagnosticsDbContext, TDbContext>();
     husky.Services.AddScoped <IDiagnosticsLogger, DiagnosticsLogger>();
     return(husky);
 }
예제 #3
0
 public static HuskyServiceHub AddKeyValueManager <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, IKeyValueDbContext
 {
     husky.Services.AddDbContext <IKeyValueDbContext, TDbContext>();
     husky.Services.AddSingleton <IKeyValueManager, KeyValueManager>();
     return(husky);
 }
예제 #4
0
 public static HuskyServiceHub AddFileStoreLogger <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, IFileStoreDbContext
 {
     husky.Services.AddDbContext <IFileStoreDbContext, TDbContext>();
     husky.Services.AddScoped <IFileStoreLogger, FileStoreLogger>();
     return(husky);
 }
예제 #5
0
 public static HuskyServiceHub AddTwoFactor(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services
     .AddDbContextPool <ITwoFactorDbContext, TwoFactorDbContext>(optionsAction)
     .AddScoped <ITwoFactorManager, TwoFactorManager>();
     return(husky);
 }
예제 #6
0
 public static HuskyServiceHub AddPrincipalAdmin <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, IAdminsDbContext
 {
     husky.Services.AddDbContext <IAdminsDbContext, TDbContext>();
     husky.Services.AddScoped <IPrincipalAdmin, PrincipalAdmin>();
     return(husky);
 }
예제 #7
0
        public static HuskyServiceHub AddAliyunSms(this HuskyServiceHub husky, Action <AliyunSmsOptions> setupAction)
        {
            var options = new AliyunSmsOptions();

            setupAction(options);
            husky.Services.AddSingleton <ISmsSender>(new AliyunSmsSender(options));
            return(husky);
        }
예제 #8
0
 public static HuskyServiceHub AddTwoFactor <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, ITwoFactorDbContext
 {
     husky.Services
     .AddDbContext <ITwoFactorDbContext, TDbContext>()
     .AddScoped <ITwoFactorManager, TwoFactorManager>();
     return(husky);
 }
예제 #9
0
        public static HuskyServiceHub AddAliyunOssBucket(this HuskyServiceHub husky, Action <AliyunOssBucketOptions> setupAction)
        {
            var options = new AliyunOssBucketOptions();

            setupAction(options);
            husky.Services.AddSingleton <ICloudFileBucket>(new AliyunOssBucket(options));
            return(husky);
        }
예제 #10
0
        public static HuskyServiceHub AddQQLbs(this HuskyServiceHub husky, Action <QQLbsOptions> setupAction)
        {
            var options = new QQLbsOptions();

            setupAction(options);
            husky.Services.AddSingleton <ILbs>(new QQLbsService(options));
            return(husky);
        }
예제 #11
0
        public static HuskyServiceHub AddAlipay(this HuskyServiceHub husky, Action <AlipayOptions> setupAction)
        {
            var options = new AlipayOptions();

            setupAction(options);
            husky.Services.AddSingleton(new AlipayService(options));
            return(husky);
        }
예제 #12
0
 public static HuskyServiceHub AddWeChatIntegration(this HuskyServiceHub husky, WeChatOptions options)
 {
     husky.Services.AddScoped(svc =>
                              new WeChatService(
                                  options,
                                  svc.GetRequiredService <IHttpContextAccessor>(),
                                  svc.GetRequiredService <IMemoryCache>()
                                  )
                              );
     return(husky);
 }
예제 #13
0
        public static HuskyServiceHub AddIdentityManager(this HuskyServiceHub husky, IdentityOptions?options = null)
        {
            husky.Services.AddScoped <IIdentityManager>(svc => {
                var http = svc.GetRequiredService <IHttpContextAccessor>().HttpContext;
                if (http == null)
                {
                    throw new InvalidProgramException($"IHttpContextAccessor.HttpContext is null here.");
                }

                return((options?.Carrier) switch {
                    IdentityCarrier.Header => new HeaderIdentityManager(http, options),
                    IdentityCarrier.Session => new SessionIdentityManager(http, options),
                    _ => new CookieIdentityManager(http, options),
                });
            });
예제 #14
0
 public static HuskyServiceHub AddQQLbs(this HuskyServiceHub husky, QQLbsOptions options)
 {
     husky.Services.AddSingleton <ILbs>(new QQLbsService(options));
     return(husky);
 }
예제 #15
0
 public static HuskyServiceHub AddQQLbs(this HuskyServiceHub husky, string key)
 {
     husky.Services.AddSingleton <ILbs>(new QQLbsService(key));
     return(husky);
 }
예제 #16
0
 public static HuskyServiceHub AddKeyValueManager(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services.AddDbContextPool <IKeyValueDbContext, KeyValueDbContext>(optionsAction);
     husky.Services.AddSingleton <IKeyValueManager, KeyValueManager>();
     return(husky);
 }
예제 #17
0
 public static HuskyServiceHub AddFileStoreLogger(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services.AddDbContextPool <IFileStoreDbContext, FileStoreDbContext>(optionsAction);
     husky.Services.AddScoped <IFileStoreLogger, FileStoreLogger>();
     return(husky);
 }
예제 #18
0
 public static HuskyServiceHub AddAliyunOssBucket(this HuskyServiceHub husky, AliyunOssBucketOptions options)
 {
     husky.Services.AddSingleton <ICloudFileBucket>(new AliyunOssBucket(options));
     return(husky);
 }
예제 #19
0
 public static HuskyServiceHub AddLocalFileBucket(this HuskyServiceHub husky, string fileBucketRootPath)
 {
     husky.Services.AddSingleton <IFileBucket>(new LocalFileBucket(fileBucketRootPath));
     return(husky);
 }
예제 #20
0
 public static HuskyServiceHub AddAlipay(this HuskyServiceHub husky, AlipayOptions options)
 {
     husky.Services.AddSingleton(new AlipayService(options));
     return(husky);
 }
예제 #21
0
 public static HuskyServiceHub AddAliyunSms(this HuskyServiceHub husky, AliyunSmsOptions options)
 {
     husky.Services.AddSingleton <ISmsSender>(new AliyunSmsSender(options));
     return(husky);
 }
예제 #22
0
 public static HuskyServiceHub AddDiagnostics(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services.AddDbContextPool <IDiagnosticsDbContext, DiagnosticsDbContext>(optionsAction);
     husky.Services.AddScoped <IDiagnosticsLogger, DiagnosticsLogger>();
     return(husky);
 }
예제 #23
0
 public static HuskyServiceHub AddMailSender(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services.AddDbContextPool <IMailDbContext, MailDbContext>(optionsAction);
     husky.Services.AddScoped <IMailSender, MailSender>();
     return(husky);
 }
예제 #24
0
 public static HuskyServiceHub AddPrincipalAdmin(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services.AddDbContextPool <IAdminsDbContext, AdminsDbContext>(optionsAction);
     husky.Services.AddScoped <IPrincipalAdmin, PrincipalAdmin>();
     return(husky);
 }