public static APIKeyManger GetInstance() { if (_singleton == null) { _singleton = new APIKeyManger(); } return(_singleton); }
public dynamic GetValue() { string url = "http://api.openweathermap.org/data/2.5/weather?id=" + CityID + "&APPID=" + APIKeyManger.GetInstance().GetApiKey("OpenWeather"); var request = WebRequest.Create(url); request.Credentials = CredentialCache.DefaultCredentials; var response = request.GetResponse(); var dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); // Read the content. string json = reader.ReadToEnd(); dynamic temperatureData = JsonConvert.DeserializeObject(json); // Display the content. response.Close(); reader.Close(); double result = temperatureData.main.temp; switch (SelectedMessurement) { case Messurement.Celius: result -= 273.15; break; } return(result); }