本文整理汇总了C#中Weather.GetWeather方法的典型用法代码示例。如果您正苦于以下问题:C# Weather.GetWeather方法的具体用法?C# Weather.GetWeather怎么用?C# Weather.GetWeather使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weather
的用法示例。
在下文中一共展示了Weather.GetWeather方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendResponse
protected override void SendResponse()
{
_weather = new Weather(Route.Value); // value the city to get weather
Tuple<WeatherCondition, WeatherWind, WeatherAtmosphere, WeatherAstronomy> resWeather = _weather.GetWeather();
string _path = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
string _pathToFolder = _path + "\\Website\\Styles\\SimplePageStyle.css";
string css = string.Empty;
using (System.IO.StreamReader reader = new System.IO.StreamReader(_pathToFolder))
{
css = reader.ReadToEnd();
}
string html = "<html>" +
"<head>" +
"<title>Weaher</title>" +
"<style type=\"text/css\">" + css + "</style>" +
"</head>" +
"<body>" +
"<h2>" + this._weather.GetTitle() + "</h2>" +
"<h3>Weather conditaion: </h3>" + "<hr>" +
"<h4>Condition: </h4> <i>" + resWeather.Item1.Conditions + "</i>" +
"<h4>Temperature: </h4> <i>" + resWeather.Item1.Temp + "</i>" +
"<h4>Code: </h4> <i>" + resWeather.Item1.Code + "</i>" +
"<h4>Date: </h4> <i>" + resWeather.Item1.Date + "</i>" +
"<h3>Weather wind: </h3>" + "<hr>" +
"<h4>Chill: </h4> <i>" + resWeather.Item2.Chill + "</i>" +
"<h4>Direction: </h4> <i>" + resWeather.Item2.Direction + "</i>" +
"<h4>Speed: </h4> <i>" + resWeather.Item2.Speed + "</i>" +
"<h4>Date: </h4> <i>" + resWeather.Item1.Date + "</i>" +
"<h3>Weather astronomy: </h3>" + "<hr>" +
"<h4>Sunrise: </h4> <i>" + resWeather.Item4.Sunrise + "</i>" +
"<h4>Sunset: </h4> <i>" + resWeather.Item4.Sunset + "</i>" +
"</body>" +
"</html>";
ResponseBuilder builder = new PageBuilder()
{
Response = new Response()
{
AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork,
IsConnected = true,
Html = html,
ContentLength = html.Length,
StatusDesc = ((HttpStatusCode)200).ToString(),
ContentType = "text/html",
StatusCode = 200,
Charset = System.Text.Encoding.UTF8,
DateTimeResponse = DateTime.Now,
ProtocolType = System.Net.Sockets.ProtocolType.Tcp
}
};
string str = builder.CreateResponse();
// Приведем строку к виду массива байт
byte[] buffer = Encoding.UTF8.GetBytes(str);
// Отправим его клиенту
this.Client.GetStream().Write(buffer, 0, buffer.Length);
// Закроем соединение
this.Client.Close();
}