private static void RegisterServices(IServiceCollection services, SDKOptions options)
 {
     services
     .AddSingleton <SDKOptions>(options)
     .AddTransient <IModelValidator, DefaultModelValidator>()
     .AddTransient <IRestClient, RestClient>((provider) =>
     {
         var restClient = new RestClient();
         restClient.UseNewtonsoftJson();
         return(restClient);
     })
     .AddSingleton <IAuthorizator, DefaultAuthorizator>()
     .AddTransient(typeof(LogMidleware <,>))
     .AddTransient(typeof(ValidateMidleware <,>))
     .AddTransient(typeof(RequestMidleware <,>))
     .AddTransient(typeof(IPipelineBehavior <,>), typeof(PipelineDefaultBehavior <,>))
     //services
     .AddTransient <IAuthenticateService, AuthenticateService>()
     .AddTransient <IReceivableService, ReceivableService>()
     .AddTransient <IAdvancementService, AdvancementService>()
     .AddTransient <ICommercialEstablishmentService, CommercialEstablishmentService>()
     .AddTransient <INotificationService, NotificationService>()
     .AddTransient <ITransactionService, TransactionService>()
     .AddTransient <ISettlementService, SettlementService>()
     .AddTransient <IPositionService, PositionService>()
     .AddTransient <IContractService, ContractService>()
     .AddTransient <IContractService, ContractService>()
     .AddTransient <IConsentService, ConsentService>()
     .AddTransient <IReconciliationService, ReconciliationService>();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 判断选项是否有效.
        /// </summary>
        /// <returns><c>true</c>, 有效, <c>false</c> 无效.</returns>
        /// <param name="iOption">选项.</param>
        public bool IsOptionValid(SDKOptions iOption)
        {
            if (SDKOptions.None == iOption)
            {
                return(data == (int)iOption);
            }

            return((data & (int)iOption) == (int)iOption);
        }
        public static IServiceCollection AddTagSDK(this IServiceCollection services, Action <SDKOptions> actOptions)
        {
            var options = new SDKOptions();

            actOptions(options);

            RegisterServices(services, options);

            return(services);
        }
        public static TagServiceCollection GetServices(Action <SDKOptions> actOptions)
        {
            if (_factory == null)
            {
                IServiceCollection serviceCollection = new ServiceCollection();

                var options = new SDKOptions();
                actOptions(options);

                RegisterServices(serviceCollection, options);

                _factory = new TagServiceCollection(serviceCollection.BuildServiceProvider());
            }

            return(_factory);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 设定选项.
 /// </summary>
 /// <param name="iOption">选项.</param>
 /// <param name="iIsOn">true:On; false:Off.</param>
 public void SetOptionOnOrOff(SDKOptions iOption, bool iIsOn)
 {
     if (iIsOn)
     {
         if (SDKOptions.None == iOption)
         {
             data = (int)SDKOptions.None;
         }
         else
         {
             data |= (int)iOption;
         }
     }
     else
     {
         data &= ~(int)iOption;
     }
 }
Exemplo n.º 6
0
 public AuthenticateService(IServiceProvider provider, SDKOptions options) : base(provider, options)
 {
 }
 public ReceivableService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
Exemplo n.º 8
0
 public SettlementService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
Exemplo n.º 9
0
 public PositionService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
Exemplo n.º 10
0
 public ContractService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
 public NotificationService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
Exemplo n.º 12
0
 public CommercialEstablishmentService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
 public DefaultAuthorizator(IAuthenticateService authenticateService, SDKOptions options)
 {
     AuthenticateService = authenticateService;
     Options             = options;
 }
 public TransactionService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
 public BaseService(IServiceProvider serviceProvider, SDKOptions options)
 {
     ServiceProvider = serviceProvider;
     Options         = options;
 }
 public ReconciliationService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }
Exemplo n.º 17
0
 public AdvancementService(IServiceProvider serviceProvider, SDKOptions options) : base(serviceProvider, options)
 {
 }