当前位置: 首页>>代码示例>>C#>>正文


C# Weather.ToString方法代码示例

本文整理汇总了C#中Weather.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Weather.ToString方法的具体用法?C# Weather.ToString怎么用?C# Weather.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Weather的用法示例。


在下文中一共展示了Weather.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyWeatherPattern

        private static void ApplyWeatherPattern(BsonDocument weather, Weather weatherEnum, BsonArray intensityArray, int intensity, BsonDocument pattern, List<string> zones)
        {
            //this tuple will contain the increase/decrease sequence
              Tuple<string, int> tupe = null;

              //if the previous pattern is not CLEAR and the previous pattern is the same as the previous
              //then we are going to see if the intensity maybe changed
              if (weather["CurrentType"].AsString != "Clear" && weather["CurrentType"].AsString == weatherEnum.ToString()) {
                  BsonDocument oldPattern = intensityArray[weather["CurrentIntensity"].AsInt32][((WeatherStrength)weather["CurrentIntensity"].AsInt32).ToString().CamelCaseWord()].AsBsonDocument;
                  //intensity increased
                  if (intensity > weather["CurrentIntensity"].AsInt32) {
                      tupe = Tuple.Create<string, int>(oldPattern["Increase"].AsString, 30);
                  }
                  //intensity decreased
                  else if (intensity < weather["CurrentIntensity"].AsInt32) {
                      tupe = Tuple.Create<string, int>(oldPattern["Decrease"].AsString, 30);
                  }
              }
              //the previous pattern is now clearing because the new pattern is clear
              else if (weatherEnum.ToString() == "Clear") {
                  //let's get the end sequence
                  BsonDocument oldPattern = intensityArray[weather["CurrentIntensity"].AsInt32][((WeatherStrength)weather["CurrentIntensity"].AsInt32).ToString().CamelCaseWord()].AsBsonDocument;
                  BsonArray endSequence = oldPattern["EndSequence"].AsBsonArray;
                  Func<BsonArray, Tuple<string, int>, string, string, bool> endScript = GetScript(zones);
                  //execute the script
                  while (endScript(endSequence, tupe, weatherEnum.ToString().ToUpper(), pattern["Message"].AsString)) { tupe = null; }
              }
              //it's other than CLEAR and it's not the same intensity
              if (weatherEnum != Weather.Clear && weather["CurrentIntensity"].AsInt32 != intensity) {
                  BsonArray startSequence = pattern["StartSequence"].AsBsonArray;
                  Func<BsonArray, Tuple<string, int>, string, string, bool> script = GetScript(zones);
                  while (script(startSequence, tupe, weatherEnum.ToString().ToUpper(), pattern["Message"].AsString)) { tupe = null; }
              }
        }
开发者ID:vadian,项目名称:Novus,代码行数:34,代码来源:Calendar.cs

示例2: GetNewWeatherPattern

        private static BsonDocument GetNewWeatherPattern(BsonDocument weather, out Weather weatherEnum, out string type)
        {
            int rand = Extensions.RandomNumber.GetRandomNumber().NextNumber(0, weather["Types"].AsBsonArray.Count);
              //we need enums for the previous and now new pattern
              weatherEnum = Weather.Clear;
              Weather previousWeather = Weather.Clear;
              //define the new pattern
              weatherEnum = (Weather)rand;

              //Did this to prevent a Null Ref Exception
              type = weatherEnum.ToString().ToUpper();

              //get the wheather pattern we want to run through the auto script, we have to peel back a few layers first
              BsonArray drizArray = weather["Types"].AsBsonArray;

              //if the weather is clear
              if (weatherEnum == Weather.Clear) {
                  //and the previous weather was clear we are done
                  if (weather["CurrentType"].AsString.ToUpper() == "CLEAR") {
                      return null;
                  }
                  //if it's not CLEAR grab the previous weather type so we can run the end sequence script
                  previousWeather = (Weather)Enum.Parse(typeof(Weather), weather["CurrentType"].AsString.ToUpper());
                  type = previousWeather.ToString(); //since it's clear we want all the previous information so we can run the end sequence properly
              }

              //keep peeling back layers now that we have the weather type
              BsonDocument weatherType = new BsonDocument();
              string typeNotAsOut = type; //lambdas don't like ref or out values, the things you learn...
              return drizArray.Where(d => d["Name"].AsString.ToUpper() == typeNotAsOut).SingleOrDefault().AsBsonDocument;
        }
开发者ID:vadian,项目名称:Novus,代码行数:31,代码来源:Calendar.cs

示例3: Speak

        private void Speak()
        {
            bool e = button1.Enabled;
            button1.Enabled = false;
            W = new Weather();
            HttpWebRequest WR;
            HttpWebResponse WResp;
            StreamReader SR;
            try
            {
                WR = (HttpWebRequest)WebRequest.Create("http://export.yandex.ru/weather-ng/forecasts/" + CL[listBox1.SelectedIndex].ID + ".xml");
                WResp = (HttpWebResponse)WR.GetResponse();
                SR = new StreamReader(WResp.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            }
            catch
            {
                System.Console.Beep();
                System.Console.Beep();
                System.Console.Beep();
                Voice.SpeakAsync("Произошла ошибка при получении данных!");
                return;
            }

            var S = SR.ReadToEnd();
            SR.Close();
            W.call = CL[listBox1.SelectedIndex].Call;
            try
            {
                W.temp = Regex.Split(S, "(?:.*)<temperature color=\"(?:.*)\" plate=\"(?:.*)\">(.*)</temperature>(?:.*)")[1];
                W.Os = Regex.Split(S, "(?:.*)<weather_type>(.*)</weather_type>(?:.*)")[1];
                W.pressure = Regex.Split(S, "(?:.*)<pressure units=\"(?:.*)\">(.*)</pressure>(?:.*)")[1];
                W.humidity = Regex.Split(S, "(?:.*)<humidity>(.*)</humidity>(?:.*)")[1];
                var stmp = Regex.Split(S, "(?:.*)<wind_direction>(.*)</wind_direction>(?:.*)")[1];
                switch (stmp)
                {
                    case "w": { W.wind = "западный"; } break;
                    case "n": { W.wind = "северный"; }; break;
                    case "s": { W.wind = "южный"; }; break;
                    case "e": { W.wind = "восточный"; }; break;
                    case "sw": { W.wind = "юго-западный"; }; break;
                    case "ws": { W.wind = "юго-западный"; }; break;
                    case "nw": { W.wind = "северо-западный"; }; break;
                    case "wn": { W.wind = "северо-западный"; }; break;
                    case "se": { W.wind = "юго-восточный"; }; break;
                    case "es": { W.wind = "юго-восточный"; }; break;
                    case "en": { W.wind = "северо-восточный"; }; break;
                    case "ne": { W.wind = "северо-восточный"; }; break;
                }
                W.speed = Regex.Split(S, "(?:.*)<wind_speed>(.*)</wind_speed>(?:.*)")[1];
            }
            catch
            {
                System.Console.Beep();
                System.Console.Beep();
                Voice.SpeakAsync("Произошла ошибка при переводе данных!");
                return;
            }
            W.temp += '°';
            W.humidity += '%';
            Voice.SpeakAsync(W.ToString());
        }
开发者ID:1extra,项目名称:prog2015,代码行数:61,代码来源:Form1.cs


注:本文中的Weather.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。