static void Main(string[] args) { var wheatherData = new WheatherData(); wheatherData.Temperature = 15.25f; wheatherData.Pressure = 25.25f; wheatherData.Humidity = 28.11f; var conditionDisplay = new CurrentConditionDisplay(wheatherData); var statisticsDisplay = new StatisticsDisplay(wheatherData); var heatIndexDisplay = new HeatIndexDisplay(wheatherData); wheatherData.Humidity = 32.11f; wheatherData.RemoveObserver(statisticsDisplay); wheatherData.Pressure = 35.99f; wheatherData.RegisterObserver(statisticsDisplay); wheatherData.Humidity = 11.11f; wheatherData.Pressure = 11.22f; wheatherData.Pressure = 11.22f; wheatherData.Pressure = 22.22f; wheatherData.Temperature = -115.25f; }
static void Main(string[] args) { var wheatherData = new WheatherData { Temperature = 15.25f, Pressure = 25.25f, Humidity = 28.11f }; var conditionDisplay = new CurrentConditionDisplay(wheatherData); var statisticsDisplay = new StatisticsDisplay(wheatherData); var heatIndexDisplay = new HeatIndexDisplay(wheatherData); wheatherData.Humidity = 32.11f; wheatherData.WheatherDataChanged -= statisticsDisplay.Update; wheatherData.Pressure = 35.99f; wheatherData.WheatherDataChanged += statisticsDisplay.Update; wheatherData.Humidity = 11.11f; wheatherData.Pressure = 11.22f; wheatherData.Pressure = 11.22f; wheatherData.Pressure = 22.22f; wheatherData.Temperature = -115.25f; }
async void OnButtonClicked(Object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(cityEntry.Text)) { WheatherData wheatherData = await _restService.GetWheatherDataAsync(GenerateRequestUri(Constantes.OpenWeatherMapEndpoint)); BindingContext = wheatherData; } }
public async Task <WheatherData> GetWheatherDataAsync(string uri) { WheatherData wheatherdata = null; try { HttpResponseMessage response = await _client.GetAsync(uri); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); wheatherdata = JsonConvert.DeserializeObject <WheatherData>(content); } } catch (Exception ex) { Debug.WriteLine("\tERROR {0}", ex.Message); } return(wheatherdata); }