public static string Select(YahooXmlData data, string opt, int day = -1) { if (data == null) throw new Exception("YahooXmlData is invalid when pick data from it"); if (day < 0) { switch (opt) { case "lastbuilddate": return data.channel.lastbuilddate; case "city": return data.channel.location.city; case "region": return data.channel.location.region; case "country": return data.channel.location.country; case "chill": return data.channel.wind.chill; case "direction": return data.channel.wind.direction; case "speed": return data.channel.wind.speed; case "humidity": return data.channel.atmosphere.humidity; case "visibility": return data.channel.atmosphere.visibility; case "pressure": return data.channel.atmosphere.pressure; case "rising": return data.channel.atmosphere.rising; case "sunrise": return data.channel.astronomy.sunrise; case "sunset": return data.channel.astronomy.sunset; case "lat": return data.channel.item.lat; case "long": return data.channel.item.Long; case "text": return data.channel.item.condition.text; case "code": return data.channel.item.condition.code; case "temp": return data.channel.item.condition.temp; case "date": return data.channel.item.condition.date; default: throw new Exception("Can't find item such as " + opt); } } else { int futurenum = data.channel.item.forecasts.Count; day = day > futurenum ? futurenum : day; switch (opt) { case "day": return data.channel.item.forecasts[day].day; case "date": return data.channel.item.forecasts[day].date; case "low": return data.channel.item.forecasts[day].low; case "high": return data.channel.item.forecasts[day].high; case "text": return data.channel.item.forecasts[day].text; case "code": return data.channel.item.forecasts[day].code; default: throw new Exception("Can't find item such as " + opt); } } }
private void OnSourceUpdate(Object sender, WeatherEventArgs e) { _data = e.data; if (_data != null) { SetRetString(); } }
public WeatherEventArgs(YahooXmlData data) { this.data = data; }