public async Task <string> GetWhetherInfoSerialized(string city) { this.city = city; url += city; WheatherInfo result = new WheatherInfo(); if (await Initialization()) { result.temperature = GetTemperature(); result.speed = GetSpeed(); result.humadity = GetHumadity(); result.pressure = GetPressure(); string resultStr; using (var output = new StringWriter()) { using (var writer = new XmlTextWriter(output) { Formatting = Formatting.Indented }) { var dataContractSerializer = new DataContractSerializer(typeof(WheatherInfo)); dataContractSerializer.WriteObject(writer, result); resultStr = output.GetStringBuilder().ToString(); } } return(resultStr); } return(null); }
public async Task <WheatherInfo> GetWhetherInfo(string city) { this.city = city; url += city; WheatherInfo result = new WheatherInfo(); await Initialization(); result.temperature = "Сейчас: " + GetTemperature(); result.speed = GetSpeed(); result.humadity = GetHumadity(); result.pressure = GetPressure(); return(result); }