public List <FeatureToggle> GetFeatureToggles() { using (var client = new HttpClient()) { SetRequestHeader(client); client.Timeout = _mogglesConfigurationManager.GetTimeoutValue(); string urlWithParams = GetUrlParams(); HttpResponseMessage response; string featureToggles; try { response = client.GetAsync(urlWithParams).Result; featureToggles = response.Content.ReadAsStringAsync().Result; } catch (AggregateException ex) { _featureToggleLoggingService.TrackException(ex, _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); throw new MogglesClientException("An error occurred while getting the feature toggles from the server!"); } if (!response.IsSuccessStatusCode) { _featureToggleLoggingService.TrackException(new MogglesClientException("An error occurred while getting the feature toggles from the server!"), _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); throw new MogglesClientException( "An error occurred while getting the feature toggles from the server!"); } return(JsonConvert.DeserializeObject <List <FeatureToggle> >(featureToggles)); } }
private string[] GetDeployedFeatureToggles() { Assembly[] assemblies = GetValidAssemblies(); List <string> featureToggleNames = new List <string>(); foreach (var domainAssembly in assemblies) { try { Type[] assemblyTypes = domainAssembly.GetTypes(); var assemblyFeatureToggleNames = (from assemblyType in assemblyTypes where assemblyType.IsSubclassOf(typeof(MogglesFeatureToggle)) select assemblyType.Name).ToList(); featureToggleNames.AddRange(assemblyFeatureToggleNames); } catch (ReflectionTypeLoadException ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"CurrentDomainAssembly={domainAssembly.FullName}"); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); } _featureToggleLoggingService.TrackException(ex, sb.ToString(), _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); } } return(featureToggleNames.ToArray()); }
public List <FeatureToggle> GetFeatureTogglesFromCache() { var featureToggles = _cache.GetFeatureTogglesFromCache(MogglesConfigurationKeys.FeatureTogglesCacheKey); if (FeatureTogglesExist(featureToggles)) { return(featureToggles); } var previouslyCachedFeatureToggles = _cache.GetFeatureTogglesFromCache(MogglesConfigurationKeys.PreviouslyCachedFeatureTogglesCacheKey); if (FeatureTogglesExist(previouslyCachedFeatureToggles)) { return(previouslyCachedFeatureToggles); } _featureToggleLoggingService.TrackException(new MogglesClientException("Feature toggles were not cached and previous values were not available!"), _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); return(new List <FeatureToggle>()); }