Beispiel #1
0
 public ArticleApiService(ILogger <ArticleApiService> logger, HttpClient httpClient, EnvironmentVariableKeys environmentVariableKeys)
 {
     _environmentVariableKeys = environmentVariableKeys;
     _logger                 = logger;
     _httpClient             = httpClient;
     _apiBaseUrl             = Environment.GetEnvironmentVariable(_environmentVariableKeys.ArticleApiBaseUrl);
     _httpClient.BaseAddress = new Uri(_apiBaseUrl);
 }
Beispiel #2
0
        public EnvironmentType GetEnvironmentType()
        {
            int environmentTypeCode;

            string environmentVariableKey =
                EnvironmentVariableKeys.GetEnvironmentVariableKey(EnvironmentVariableKey.EnvironmentType);

            if (int.TryParse(Environment.GetEnvironmentVariable(environmentVariableKey), out environmentTypeCode))
            {
                return((EnvironmentType)environmentTypeCode);
            }

            if (int.TryParse(ConfigurationManager.AppSettings[environmentVariableKey], out environmentTypeCode))
            {
                return((EnvironmentType)environmentTypeCode);
            }

            throw new MissingEnvironmentVariableException($"Missing OS Environment Variable name: {environmentVariableKey}");
        }