public static List <PaymentProviderSetting> GetAllProviders() { //Config file takes precedence over database ProviderConfigurationHandler config = ConfigurationManager.GetSection("PaymentProvider") as ProviderConfigurationHandler; if (ConfigurationManager.AppSettings["DBPaymentGateway"] == null) { return(GetAllProvidersFromDB(true)); } else if (Convert.ToBoolean(ConfigurationManager.AppSettings["DBPaymentGateway"])) { return(GetAllProvidersFromDB(true)); } else { if (config != null && config.Providers != null && config.Providers.Count > 0) { return(config.Providers); } else { return(GetAllProvidersFromDB(true)); } } }
public static IServiceCollection RegisterGloryServices(this IServiceCollection services, IConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } services.AddTransient <CacheProviderConfiguration>(); var cacheProviderConfig = ProviderConfigurationHandler.Create <CacheProviderConfiguration>(configuration.GetSection("caching")); if (cacheProviderConfig != null) { services.AddMemoryCache(); cacheProviderConfig.RegisterProvidersType(services); services.AddTransient((sp) => cacheProviderConfig); } var eventQueueProviderConfig = ProviderConfigurationHandler.Create <EventQueueProviderConfiguration>(configuration.GetSection("eventQueue")); if (eventQueueProviderConfig != null) { services.AddSingleton <IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>(); services.AddSingleton <IExternalSubscriptionsManager, ExternalSubscriptionsManager>(); services.AddTransient <ExternalSubscriberHandler>(); services.AddTransient <InsideEventQueueProvider>(); eventQueueProviderConfig.RegisterProvidersType(services); services.AddTransient((sp) => eventQueueProviderConfig); } var dataStoreProviderConfig = ProviderConfigurationHandler.Create <DataStoreProviderConfiguration>(configuration.GetSection("dataStore")); if (dataStoreProviderConfig != null) { dataStoreProviderConfig.RegisterProvidersType(services); services.AddTransient((sp) => dataStoreProviderConfig); } return(services); }