Пример #1
0
        public async Task <TConfig> GetConfigAsync <TConfig>(string clientId) where TConfig : class, new()
        {
            var client = await configurationClientService.GetClientOrDefault(clientId);

            if (client == null)
            {
                throw new ConfigurationClientNotFoundException(clientId);
            }
            var config = await configProvider.GetAsync <TConfig>(new ConfigurationIdentity(client, registry.GetVersion())).ConfigureAwait(false);

            return(config.Configuration);
        }
Пример #2
0
 public async Task LoadByKeysAsync(params string[] keys)
 {
     foreach (var key in keys)
     {
         configs.Add(key, await provider.GetAsync(key));
     }
 }
Пример #3
0
        public async Task <ConfigInstance> GetAsync(Type type, ConfigurationIdentity id)
        {
            var model          = registry.GetConfigDefinition(type);
            var configInstance = await configProvider.GetAsync(type, id);

            UpdateOptions(configInstance.GetConfiguration(), model.ConfigurationProperties);
            return(configInstance);
        }
        private async Task BuildConfigurations(ConfigurationSet result, ConfigurationSetModel setDefinition, Type setType, IEnumerable <ConfigurationSet> configurationSets, ConfigurationIdentity identity)
        {
            var configurationDependencies = configurationSets.Concat(new[] { result }).ToArray();

            foreach (var configDefinition in setDefinition.Configs.Where(w => !(w is ConfigurationOptionModel)))
            {
                var configInstance = await configProvider.GetAsync(configDefinition.Type, identity);

                var configuration = configInstance.GetConfiguration();
                UpdateOptions(configuration, configDefinition.ConfigurationProperties, configurationDependencies, identity);
                configDefinition.SetConfigurationOnConfigurationSet(result, configuration);
            }
        }
Пример #5
0
        private async Task ReloadCertificateIfNotAlreadyDone()
        {
            if (currentCertificate != null)
            {
                return;
            }

            try
            {
                var sslCert = await configProvider.GetAsync(ConfigNames.SslCert);

                var sslCertPw = await configProvider.GetAsync(ConfigNames.SslCertPw);

                currentCertificate      = new X509Certificate2(Convert.FromBase64String(sslCert), sslCertPw);
                lastCertificateLoadTime = DateTime.UtcNow;

                logger.LogInformation($"The new server ssl certificate is going to expire at {currentCertificate?.NotAfter}");
            }
            catch (Exception exce)
            {
                logger.LogError(exce, "Loading the new server ssl certificate failedd");
            }
        }
Пример #6
0
        public async Task <TConfig> BuildConfigAsync <TConfig>() where TConfig : class, new()
        {
            var config = await configProvider.GetAsync <TConfig>(applicationId);

            return(config.Configuration);
        }