private List <IFeatureToggle> GetFeatureToggles(JsonServiceInfo serviceInfo)
        {
            var result = new List <IFeatureToggle>();

            var client = new WebClient();

            client.Headers.Add("content-type", "application/json");

            try
            {
                var response = client.DownloadString(serviceInfo.Url);
                result = JsonConvert.DeserializeObject <List <IFeatureToggle> >(response, new FeatureToggleConverter(serviceInfo.RootAssembly, serviceInfo.FeatureToggleNamespace));
            }
            catch (WebException exception)
            {
                string responseText;

                using (var reader = new StreamReader(exception.Response.GetResponseStream()))
                {
                    responseText = reader.ReadToEnd();
                }
            }

            return(result);
        }
 public JsonTogglerApiService(JsonServiceInfo serviceInfo)
 {
     _featureToggles = this.GetFeatureToggles(serviceInfo);
     if (_featureToggles == null)
     {
         _featureToggles = new List <IFeatureToggle>();
     }
 }
        private List <IFeatureToggle> GetFeatureToggles(JsonServiceInfo serviceInfo)
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.BaseAddress = serviceInfo.BaseAddress;

            var myTask   = client.GetAsync(serviceInfo.Endpoint);
            var response = myTask.Result;

            var result = new List <IFeatureToggle>();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var resultJson = response.Content.ReadAsStringAsync().Result;
                result = JsonConvert.DeserializeObject <List <IFeatureToggle> >(resultJson, new FeatureToggleConverter(serviceInfo.RootAssembly, serviceInfo.FeatureToggleNamespace));
            }
            else
            {
                var responseMessage = response.Content.ReadAsStringAsync();
            }

            return(result);
        }