예제 #1
0
        /// <summary>
        /// 注入支付服务
        /// </summary>
        /// <param name="cissyConfigBuilder"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static CissyConfigBuilder AddPaymentConfig(this CissyConfigBuilder cissyConfigBuilder)
        {
            ICissyConfig cissyConfig = cissyConfigBuilder.CissyConfig;

            if (cissyConfig.IsNotNull())
            {
                PaymentConfig payConfig = cissyConfig.GetConfig <PaymentConfig>();
                if (payConfig.IsNotNull())
                {
                    var factory = new DefaultPayAppFactory(payConfig);
                    cissyConfigBuilder.ServiceCollection.AddSingleton(typeof(IPayAppFactory), factory);
                }
            }
            cissyConfigBuilder.RegisterMapper(register =>
            {
                register.CreateMap <PaymentRequest, PaymentArg>().ForMember(b => b.AppName, n => n.Ignore());
            });
            return(cissyConfigBuilder);
        }
예제 #2
0
 void ConfigCissyServices(CissyConfigBuilder CissyConfigBuilder, CissyConfigSource CissyConfigSource)
 {
     if (CissyConfigSource.StartPayment)
     {
         CissyConfigBuilder.AddPaymentConfig();
     }
     if (CissyConfigSource.StartMemoryCache)
     {
         CissyConfigBuilder.AddLocalMemoryCache();
     }
     if (CissyConfigSource.StartWeakCache)
     {
         CissyConfigBuilder.AddWeakCache();
     }
     if (CissyConfigSource.StartRedis)
     {
         CissyConfigBuilder.AddRedisConfig();
     }
     if (CissyConfigSource.StartSwagger)
     {
         CissyConfigBuilder.AddCissySwaggerConfig();
     }
     if (CissyConfigSource.StartElasticsearch)
     {
         CissyConfigBuilder.AddElasticsearchConfig();
     }
     if (CissyConfigSource.StartKafka)
     {
         CissyConfigBuilder.AddKafkaConfig();
     }
     if (CissyConfigSource.StartAliOSS)
     {
         CissyConfigBuilder.AddAliOSSConfig();
     }
     if (CissyConfigSource.StartHttpProxy)
     {
         CissyConfigBuilder.AddHttpProxyConfig();
     }
     if (CissyConfigSource.StartWeixinApi.IsNotNull())
     {
         CissyConfigBuilder.AddWeiXinMpApiConfig(builder =>
         {
             return(CissyConfigSource.StartWeixinApi(CissyConfigBuilder));
         });
     }
     if (CissyConfigSource.StartRateLimit.IsNotNull())
     {
         var loaderOption = CissyConfigSource.StartRateLimit(CissyConfigBuilder);
         if (loaderOption.IsNotNull())
         {
             var cache = loaderOption.GetRedisCache();
             if (cache.IsNull())
             {
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IIpPolicyStore, MemoryCacheIpPolicyStore>();
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IClientPolicyStore, MemoryCacheClientPolicyStore>();
             }
             else
             {
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IIpPolicyStore, RedisCacheIpPolicyStore>();
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IRateLimitCounterStore, RedisCacheRateLimitCounterStore>();
                 CissyConfigBuilder.ServiceCollection.AddSingleton <IClientPolicyStore, RedisCacheClientPolicyStore>();
             }
             CissyConfigBuilder.ServiceCollection.AddSingleton <IRateLimitLoader>(loaderOption);
             CissyConfigBuilder.ServiceCollection.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
             CissyConfigBuilder.ServiceCollection.AddSingleton <IRateLimitConfiguration, RateLimitConfiguration>();
         }
     }
     if (CissyConfigSource.StartAuthentication.IsNotNull())
     {
         var option = CissyConfigSource.StartAuthentication();
         if (option.IsNotNull())
         {
             CissyConfigBuilder.AddCissyAuthentication(x =>
             {
                 x.Scheme = option.Scheme;
                 x.AuthenticationApply = option.AuthenticationApply;
                 x.AuthenticationType  = option.AuthenticationType;
             });
         }
         else
         {
             CissyConfigBuilder.AddCissyAuthentication();
         }
     }
     CissyConfigBuilder.RegisterMapper(reg =>
     {
         _RegisterDTOMap(reg);
     });
 }