Example #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);
 }
Example #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);
 }
Example #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);
 }
Example #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);
 }
Example #5
0
 public static HuskyServiceHub AddTwoFactor(this HuskyServiceHub husky, Action <DbContextOptionsBuilder> optionsAction)
 {
     husky.Services
     .AddDbContextPool <ITwoFactorDbContext, TwoFactorDbContext>(optionsAction)
     .AddScoped <ITwoFactorManager, TwoFactorManager>();
     return(husky);
 }
Example #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);
 }
Example #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);
        }
Example #8
0
 public static HuskyServiceHub AddTwoFactor <TDbContext>(this HuskyServiceHub husky)
     where TDbContext : DbContext, ITwoFactorDbContext
 {
     husky.Services
     .AddDbContext <ITwoFactorDbContext, TDbContext>()
     .AddScoped <ITwoFactorManager, TwoFactorManager>();
     return(husky);
 }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
 }
Example #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),
                });
            });
Example #14
0
 public static HuskyServiceHub AddQQLbs(this HuskyServiceHub husky, QQLbsOptions options)
 {
     husky.Services.AddSingleton <ILbs>(new QQLbsService(options));
     return(husky);
 }
Example #15
0
 public static HuskyServiceHub AddQQLbs(this HuskyServiceHub husky, string key)
 {
     husky.Services.AddSingleton <ILbs>(new QQLbsService(key));
     return(husky);
 }
Example #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);
 }
Example #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);
 }
Example #18
0
 public static HuskyServiceHub AddAliyunOssBucket(this HuskyServiceHub husky, AliyunOssBucketOptions options)
 {
     husky.Services.AddSingleton <ICloudFileBucket>(new AliyunOssBucket(options));
     return(husky);
 }
Example #19
0
 public static HuskyServiceHub AddLocalFileBucket(this HuskyServiceHub husky, string fileBucketRootPath)
 {
     husky.Services.AddSingleton <IFileBucket>(new LocalFileBucket(fileBucketRootPath));
     return(husky);
 }
Example #20
0
 public static HuskyServiceHub AddAlipay(this HuskyServiceHub husky, AlipayOptions options)
 {
     husky.Services.AddSingleton(new AlipayService(options));
     return(husky);
 }
Example #21
0
 public static HuskyServiceHub AddAliyunSms(this HuskyServiceHub husky, AliyunSmsOptions options)
 {
     husky.Services.AddSingleton <ISmsSender>(new AliyunSmsSender(options));
     return(husky);
 }
Example #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);
 }
Example #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);
 }
Example #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);
 }