コード例 #1
0
 public void InitWeatehr(Weathers weathers, string temperature)
 {
     sun.SetActive(false);
     cloud.SetActive(false);
     rain.SetActive(false);
     snow.SetActive(false);
     txtTemperature.text = (int)float.Parse(temperature) + "˚";
     if (weathers == Weathers.Clean)
     {
         sun.SetActive(true);
         txtWeather.text = "맑음";
     }
     else if (weathers == Weathers.Cloud)
     {
         cloud.SetActive(true);
         txtWeather.text = "흐림";
     }
     else if (weathers == Weathers.Rain)
     {
         rain.SetActive(true);
         txtWeather.text = "비";
     }
     else if (weathers == Weathers.Snow)
     {
         snow.SetActive(true);
         txtWeather.text = "눈";
     }
 }
コード例 #2
0
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (Weathers != null)
     {
         Weathers.WriteBinary(writer);
     }
     if (SunTexture != null)
     {
         SunTexture.WriteBinary(writer);
     }
     if (SunGlareTexture != null)
     {
         SunGlareTexture.WriteBinary(writer);
     }
     if (Model != null)
     {
         Model.WriteBinary(writer);
     }
     if (Timing != null)
     {
         Timing.WriteBinary(writer);
     }
 }
コード例 #3
0
        public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (EditorID != null)
            {
                ele.TryPathTo("EditorID", true, out subEle);
                EditorID.WriteXML(subEle, master);
            }
            if (Weathers != null)
            {
                ele.TryPathTo("Weathers", true, out subEle);
                Weathers.WriteXML(subEle, master);
            }
            if (SunTexture != null)
            {
                ele.TryPathTo("SunTexture", true, out subEle);
                SunTexture.WriteXML(subEle, master);
            }
            if (SunGlareTexture != null)
            {
                ele.TryPathTo("SunGlareTexture", true, out subEle);
                SunGlareTexture.WriteXML(subEle, master);
            }
            if (Model != null)
            {
                ele.TryPathTo("Model", true, out subEle);
                Model.WriteXML(subEle, master);
            }
            if (Timing != null)
            {
                ele.TryPathTo("Timing", true, out subEle);
                Timing.WriteXML(subEle, master);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: vwied/grpc-cs-server
        public static void Main(string[] args)
        {
            GrpcEnvironment.SetLogger(new ConsoleLogger());
            const int Port        = 5000;
            var       weatherImpl = new WeatherImpl(new WeatherService());
            var       userImpl    = new UserImpl(new UserService());
            var       pingImpl    = new PingImpl();
            Server    server      = new Server
            {
                Services =
                {
                    Weathers.BindService(weatherImpl).Intercept(new AuthInterceptor()),
                    Check.BindService(pingImpl),
                    Users.BindService(userImpl)
                },
                Ports = { new ServerPort("0.0.0.0", Port, ServerCredentials.Insecure) }
            };

            server.Start();
            GrpcEnvironment.Logger.Info("[START] Tozawa server listening on port " + Port);
            GrpcEnvironment.Logger.Info("[Other] Press any key to stop the server...");

            Console.Read();

            server.ShutdownAsync().Wait();
        }
コード例 #5
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Weathers", false, out subEle))
            {
                if (Weathers == null)
                {
                    Weathers = new WeatherList();
                }

                Weathers.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("SunTexture", false, out subEle))
            {
                if (SunTexture == null)
                {
                    SunTexture = new SimpleSubrecord <String>();
                }

                SunTexture.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("SunGlareTexture", false, out subEle))
            {
                if (SunGlareTexture == null)
                {
                    SunGlareTexture = new SimpleSubrecord <String>();
                }

                SunGlareTexture.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Model", false, out subEle))
            {
                if (Model == null)
                {
                    Model = new Model();
                }

                Model.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Timing", false, out subEle))
            {
                if (Timing == null)
                {
                    Timing = new ClimateTiming();
                }

                Timing.ReadXML(subEle, master);
            }
        }
コード例 #6
0
        public async Task <Task> ChangeDropDown(SelectedItem selectedItem)
        {
            Status = selectedItem.Text;
            Weathers Souce = await Http.GetFromJsonAsync <Weathers>(Config["ApiUrl"] + "/api/Weather");

            AllData = Souce.records.location;
            return(Task.CompletedTask);
        }
コード例 #7
0
 public WeatherListViewModel(IWeatherRepository weather)
 {
     _weather = weather;
     foreach (var entity in _weather.GetData())
     {
         Weathers.Add(new WeatherListViewModelWeather(entity));
     }
 }
コード例 #8
0
        public async Task RunAsync([TimerTrigger("0 * * * * *")] TimerInfo myTimer, ILogger log)

        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.UtcNow}");
            try
            {
                foreach (var city in Consts.Consts.Cities)
                {
                    var request = new RestRequest("forecast", Method.GET);
                    request.AddParameter("q", city, ParameterType.QueryString);
                    request.AddParameter("appid", "2b35650ce7cbe72fda4a00182e2ca32d", ParameterType.QueryString);
                    request.AddParameter("units", "metric", ParameterType.QueryString);

                    var response = await _client.ExecuteAsync(request);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var parsedData = JsonConvert.DeserializeObject <WeatherResponse>(response.Content);

                        if (parsedData != null)
                        {
                            var apiWeather = new Weathers()
                            {
                                City        = parsedData.City.Name,
                                Temperature = parsedData.List[0].Main.Temp,
                                Humidity    = parsedData.List[0].Main.Humidity,
                                WindSpeed   = parsedData.List[0].Wind.Speed,
                                Visibility  = parsedData.List[0].Visibility,
                                Sunrise     = parsedData.City.Sunrise,
                                Sunset      = parsedData.City.Sunset,
                            };

                            var singleWeather = _context.Weathers.FirstOrDefault(x => x.City == apiWeather.City);
                            if (singleWeather == null)
                            {
                                _context.Weathers.Add(apiWeather);
                            }
                            else
                            {
                                singleWeather.Temperature = apiWeather.Temperature;
                                singleWeather.Humidity    = apiWeather.Humidity;
                                singleWeather.WindSpeed   = apiWeather.WindSpeed;
                                singleWeather.Visibility  = apiWeather.Visibility;
                                singleWeather.Sunrise     = apiWeather.Sunrise;
                                singleWeather.Sunset      = apiWeather.Sunset;
                            }
                        }
                    }
                }

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                log.LogError(ex.Message);
            }
            log.LogInformation($"C# Timer trigger function ends");
        }
コード例 #9
0
 /// <summary>
 /// Represents a weather condition and all the affects it has on the orbital routes
 /// </summary>
 /// <param name="weatherType">The type of weather</param>
 /// <param name="changeInCraters">Percentage change in craters</param>
 /// <example>
 /// new Weather(Weathers.Cloudy, 10)
 /// new Weather(Weathers.Snowy, 30)
 /// new Weather(Weathers.Sleeting, 35)
 /// new Weather(Weathers.Stormy, 40)
 /// new Weather(Weathers.Hailing, 50)
 /// new Weather(Weathers.Foggy, 15)
 /// new Weather(Weathers.CleakSky, -20)
 /// new Weather(Weathers.Rainbow, -100)
 /// </example>
 /// <remarks>
 /// The decimal value denotes the percentage change in the number of craters for
 /// the given weather. Negative value means the craters are reduced by the given
 /// percentage, and a positive value means the number of craters increase by the
 /// given percentage.
 /// The decimal value should be between -100 to 100
 /// </remarks>
 public Weather(Weathers weatherType, decimal changeInCraters)
 {
     WeatherType = weatherType;
     if (changeInCraters < -100 ||
         changeInCraters > 100)
     {
         throw new ArgumentOutOfRangeException(nameof(changeInCraters), changeInCraters, $"{nameof(changeInCraters)} should be between -100 and 100");
     }
     ChangeInCraters = changeInCraters;
 }
コード例 #10
0
        private async Task SearchCity(string city)
        {
            if (city == null)
            {
                return;
            }

            var result = await _repository.GetWheater(city);

            Weathers.Add(new WeatherViewModel(result));
        }
コード例 #11
0
 public ListViewHeaderViewModel()
 {
     Task.Run(async() =>
     {
         IsBusy          = true;
         var weatherData = new WeatherDataService();
         Weathers        = (await weatherData.GetItemsAsync(1, 50)).ToList();
         SelectedWeather = Weathers.FirstOrDefault();
         IsBusy          = false;
     });
 }
コード例 #12
0
        public CurrentWeather(string apiKey, string queryStr, UnitsEnum units)
        {
            string unitsString;

            switch (units)
            {
            case UnitsEnum.Metric: { unitsString = "metric"; break; }

            case UnitsEnum.Imperial: { unitsString = "imperial"; break; }

            default: { unitsString = "standard"; break; }
            }

            JObject jsonData;

            using (var client = new System.Net.WebClient())
                jsonData = JObject.Parse(client.DownloadString($"http://api.openweathermap.org/data/2.5/weather?appid={apiKey}&q={queryStr}&units={unitsString}"));

            if (jsonData.SelectToken("cod").ToString() == "200")
            {
                ValidRequest = true;
                Coord        = new Coord(jsonData.SelectToken("coord"));
                foreach (JToken weather in jsonData.SelectToken("weather"))
                {
                    Weathers.Add(new Weather(weather));
                }
                Base = jsonData.SelectToken("base").ToString();
                Main = new Main(jsonData.SelectToken("main"));
                if (jsonData.SelectToken("visibility") != null)
                {
                    Visibility = double.Parse(jsonData.SelectToken("visibility").ToString(), CultureInfo.InvariantCulture);
                }
                Wind = new Wind(jsonData.SelectToken("wind"));
                if (jsonData.SelectToken("rain") != null)
                {
                    Rain = new Rain(jsonData.SelectToken("rain"));
                }
                if (jsonData.SelectToken("snow") != null)
                {
                    Snow = new Snow(jsonData.SelectToken("snow"));
                }
                Clouds = new Clouds(jsonData.SelectToken("clouds"));
                Sys    = new Sys(jsonData.SelectToken("sys"));
                ID     = int.Parse(jsonData.SelectToken("id").ToString(), CultureInfo.InvariantCulture);
                Name   = jsonData.SelectToken("name").ToString();
                Cod    = int.Parse(jsonData.SelectToken("cod").ToString(), CultureInfo.InvariantCulture);
            }
            else
            {
                ValidRequest = false;
            }
        }
コード例 #13
0
        public WeatherListViewModel(IWeatherRepository weather, MainWindowViewModel mainWindowViewModel)
        {
            _weather             = weather;
            _mainWindowViewModel = mainWindowViewModel;
            foreach (var entity in _weather.GetData())
            {
                Weathers.Add(new WeatherListViewModelWeather(entity));
            }

            UpdateButton             = new DelegateCommand(UpdateButtonExecute);
            DataGridSelectionChanged = new DelegateCommand(DataGridSelectionChangedExecute);
            DataGridMouseDoubleClick = new DelegateCommand(DataGridMouseDoubleClickExecute);
        }
コード例 #14
0
 public override void WriteBinary(ESPWriter writer)
 {
     if (Header != null)
     {
         Header.WriteBinary(writer);
     }
     if (ObjectList != null)
     {
         ObjectList.WriteBinary(writer);
     }
     if (MapName != null)
     {
         MapName.WriteBinary(writer);
     }
     if (GrassList != null)
     {
         GrassList.WriteBinary(writer);
     }
     if (MusicType != null)
     {
         MusicType.WriteBinary(writer);
     }
     if (Music != null)
     {
         Music.WriteBinary(writer);
     }
     if (IncidentalMediaSet != null)
     {
         IncidentalMediaSet.WriteBinary(writer);
     }
     if (BattleMediaSets != null)
     {
         foreach (var item in BattleMediaSets)
         {
             item.WriteBinary(writer);
         }
     }
     if (Sounds != null)
     {
         Sounds.WriteBinary(writer);
     }
     if (Weathers != null)
     {
         Weathers.WriteBinary(writer);
     }
     if (Imposters != null)
     {
         Imposters.WriteBinary(writer);
     }
 }
コード例 #15
0
        /// <summary>
        /// Выявить погоду на день
        /// </summary>
        /// <param name="date">Интересующая дата</param>
        private void UpdateWeatherOfDay(DateTime date)
        {
            if (WeatherOfDay?.Count > 0)
            {
                return;
            }


            for (int i = 0; i < Weathers.Count; i++)
            {
                Weathers[i].ConvertionDtTxt();
            }

            WeatherOfDay = Weathers.Where(n => n.DtAstanaAndDjako.Date == date.Date).ToList();
        }
コード例 #16
0
        private async Task LoadData()
        {
            if (_isDataLoaded)
            {
                return;
            }

            _isDataLoaded = true;

            // Our repository works with Weather objects. In this view model, we work with WeatherViewModel objects.
            // So, here I've called  LINQ Select() extension method to map these Weather objects to WeatherViewModel.
            var results = await _repository.GetSeveralCitiesWheaterAsync();

            foreach (var result in results.Weather)
            {
                Weathers.Add(new WeatherViewModel(result));
            }
        }
コード例 #17
0
        private async Task GetWeathersAsync()
        {
            CanClick = false;

            Weathers.Clear();
            // サービスの GetWeathersAsync メソッドをコールし、一時的に保存
            var tempWeathers = await _weatherService.GetWeathersAsync();

            // View から参照できるようにプロパティに流し込み
            if (tempWeathers != null)
            {
                foreach (var weather in tempWeathers)
                {
                    Weathers.Add(weather);
                }
            }

            CanClick = true;
        }
コード例 #18
0
        public Query(string apiKey, string queryStr)
        {
            JObject jsonData;

            using (var client = new System.Net.WebClient())
                jsonData = JObject.Parse(client.DownloadString($"http://api.openweathermap.org/data/2.5/weather?appid={apiKey}&q={queryStr}"));

            if (jsonData.SelectToken("cod").ToString() == "200")
            {
                ValidRequest = true;
                Coord        = new Coord(jsonData.SelectToken("coord"));
                foreach (JToken weather in jsonData.SelectToken("weather"))
                {
                    Weathers.Add(new Weather(weather));
                }
                Base = jsonData.SelectToken("base").ToString();
                Main = new Main(jsonData.SelectToken("main"));
                if (jsonData.SelectToken("visibility") != null)
                {
                    Visibility = double.Parse(jsonData.SelectToken("visibility").ToString(), CultureInfo.InvariantCulture);
                }
                Wind = new Wind(jsonData.SelectToken("wind"));
                if (jsonData.SelectToken("rain") != null)
                {
                    Rain = new Rain(jsonData.SelectToken("rain"));
                }
                if (jsonData.SelectToken("snow") != null)
                {
                    Snow = new Snow(jsonData.SelectToken("snow"));
                }
                Clouds = new Clouds(jsonData.SelectToken("clouds"));
                Sys    = new Sys(jsonData.SelectToken("sys"));
                ID     = int.Parse(jsonData.SelectToken("id").ToString(), CultureInfo.InvariantCulture);
                Name   = jsonData.SelectToken("name").ToString();
                Cod    = int.Parse(jsonData.SelectToken("cod").ToString(), CultureInfo.InvariantCulture);
                Dt     = Helper.convertUnixToDateTime(double.Parse(jsonData.SelectToken("dt").ToString(), CultureInfo.InvariantCulture));
            }
            else
            {
                ValidRequest = false;
            }
        }
 public List <Weather> GetWeathers(int month, int day)
 {
     // Select all monthes
     if (month == 12)
     {
         SelectedWeathers = Weathers.ToList();
     }
     else // Select all days
     {
         if (day == -1)
         {
             SelectedWeathers = Weathers.Where(d => d.Date.Month == month + 1).ToList();
         }
         else
         {
             SelectedWeathers = Weathers.Where(d => (d.Date.Month == month + 1) && (d.Date.Day == day + 1)).ToList();
         }
     }
     return(SelectedWeathers);
 }
コード例 #20
0
        public static void Main(string[] args)
        {
            const int Port         = 5000;
            var       weatherImple = new WeatherImpl(new WeatherService());
            Server    server       = new Server
            {
                Services =
                {
                    Weathers.BindService(weatherImple)
                },
                Ports = { new ServerPort("0.0.0.0", Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("starting server ...");
            Console.Read();

            server.ShutdownAsync().Wait();
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: YTakahashii/gRPC-Training
        public static void Main(string[] args)
        {
            const int Port        = 5000;
            var       weatherImpl = new WeatherImpl(new WeatherService());
            Server    server      = new Server
            {
                Services = { Weathers.BindService(weatherImpl) },
                Ports    = { new ServerPort("0.0.0.0", Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("Tozawa server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
            // configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(@"appsettings.json", false).Build();
            // sqlHandler = new SqlHandler();
            // CreateWebHostBuilder(args).Build().Run();
        }
コード例 #22
0
        public Hour(JToken hourData)
        {
            if (hourData is null)
            {
                throw new ArgumentNullException(nameof(hourData));
            }

            DateTime    = Utility.convertUnixToDateTime(double.Parse(hourData.SelectToken("dt").ToString(), CultureInfo.InvariantCulture));
            Temperature = double.Parse(hourData.SelectToken("temp").ToString(), CultureInfo.InvariantCulture);
            FeelsLike   = double.Parse(hourData.SelectToken("feels_like").ToString(), CultureInfo.InvariantCulture);
            Pressure    = int.Parse(hourData.SelectToken("pressure").ToString(), CultureInfo.InvariantCulture);
            Humidity    = int.Parse(hourData.SelectToken("humidity").ToString(), CultureInfo.InvariantCulture);
            DewPoint    = double.Parse(hourData.SelectToken("dew_point").ToString(), CultureInfo.InvariantCulture);
            Uvi         = double.Parse(hourData.SelectToken("uvi").ToString(), CultureInfo.InvariantCulture);
            Clouds      = int.Parse(hourData.SelectToken("clouds").ToString(), CultureInfo.InvariantCulture);
            Visibility  = int.Parse(hourData.SelectToken("visibility").ToString(), CultureInfo.InvariantCulture);
            Wind        = new Wind(hourData);
            Pop         = double.Parse(hourData.SelectToken("pop").ToString(), CultureInfo.InvariantCulture);
            foreach (JToken weather in hourData.SelectToken("weather"))
            {
                Weathers.Add(new Weather(weather));
            }
        }
コード例 #23
0
    IEnumerator IGetWeather(string lat, string lon)
    {
        PlayerPrefs.SetString("lat", lat);
        PlayerPrefs.SetString("lon", lon);

        WWW www = new WWW("http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=ce4995f5d2e026bf6ac967963210ceb1&units=metric");

        yield return(www);

        if (www.error != null)
        {
        }
        else if (www.isDone)
        {
            weatherInfo = JsonUtility.FromJson <WeatherInfo>(www.text);
            Weathers tempWeathers = Weathers.Clean;
            Debug.Log(weatherInfo);
            foreach (WeatherInfo.Weather weather in weatherInfo.weather)
            {
                if (weather.id == 800)
                {   //clear
                    //myWeather.SetWeatherInfo(Weathers.맑음);
                    tempWeathers = Weathers.Clean;
                    break;
                }
                else if (weather.id > 800 && weather.id > 805)
                { //clouds
                  //myWeather.SetWeatherInfo(Weathers.흐림);
                    tempWeathers = Weathers.Cloud;
                    break;
                }
                else if (weather.id > 599 && weather.id < 623)
                { //snowy
                  //myWeather.SetWeatherInfo(Weathers.눈);
                    tempWeathers = Weathers.Snow;
                    break;
                }
                else if (weather.id > 499 && weather.id < 532)
                { //rainy
                  //myWeather.SetWeatherInfo(Weathers.비);
                    tempWeathers = Weathers.Rain;
                    break;
                }
                else if (weather.id > 299 && weather.id < 322)
                { //drizzle
                  //myWeather.SetWeatherInfo(Weathers.비);
                    tempWeathers = Weathers.Rain;
                    break;
                }
                else if (weather.id > 199 && weather.id < 233)
                { //thunder
                  //myWeather.SetWeatherInfo(Weathers.비);
                    tempWeathers = Weathers.Rain;
                    break;
                }
                else if (weather.id > 700 && weather.id < 782)
                {//etcs
                 //myWeather.SetWeatherInfo(Weathers.흐림)
                    tempWeathers = Weathers.Cloud;
                    break;
                }
            }

            Message.Send <WeatherMsg>(new WeatherMsg(tempWeathers, weatherInfo.main.temp.ToString()));
            //myWeather.SetWeatherDegree(weatherInfo.temp + "");
            StartCoroutine(IGetLocale(lat, lon));
        }
    }
コード例 #24
0
ファイル: WatchMessage.cs プロジェクト: cjh880118/TabletHolo
 public WeatherMsg(Weathers weathers, string temperature)
 {
     this.weathers    = weathers;
     this.temperature = temperature;
 }
コード例 #25
0
 public List <Weather> GetWeathers(DateTime start, DateTime end)
 {
     return(Weathers.Where(x => (x.Date >= start) && (x.Date <= end)).ToList());
 }
コード例 #26
0
        protected override async Task OnInitializedAsync()
        {
            Weathers Souce = await Http.GetFromJsonAsync <Weathers>(Config["ApiUrl"] + "/api/Weather");

            AllData = Souce.records.location;
        }
コード例 #27
0
ファイル: ParksqlDAL.cs プロジェクト: KLane1985/krisprojects
        public async Task <IList <WeatherModel> > GinerateWeathers(string parkCode)
        {
            //get latitude and longatude from database
            double latitude, longitude;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("SELECT latitude, longitude FROM park WHERE parkCode = @parkCode", conn);
                cmd.Parameters.AddWithValue("@parkCode", parkCode);

                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();
                latitude  = Convert.ToDouble(reader["latitude"]);
                longitude = Convert.ToDouble(reader["longitude"]);
            }

            //retrieve api JSON text
            Weathers weathersJSON = null;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://api.darksky.net/forecast/abceeae83c5db281569248683cd3ef49/");

                var responseTask = client.GetAsync(latitude + "," + longitude + "?exclude=currently,minutely,hourly,alerts,flags");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    string content = await result.Content.ReadAsStringAsync();

                    weathersJSON = JsonConvert.DeserializeObject <Weathers>(content);
                }
            }

            IList <WeatherModel> weathers = new List <WeatherModel>();

            for (int i = 0; i < 5; i++)
            {
                WeatherModel weather = new WeatherModel();

                weather.Low        = (int)weathersJSON.daily.data[i].temperatureLow;
                weather.High       = (int)weathersJSON.daily.data[i].temperatureHigh;
                weather.Forecast   = weathersJSON.daily.data[i].icon;
                weather.ActualDate = DateTime.Now.AddDays(i);

                if (weather.High > 75)
                {
                    weather.TempAdvisory += "Bring an extra gallon of water! ";
                }

                if (weather.Low < 20)
                {
                    weather.TempAdvisory += "Frigid temperatures can lead to frostbite! ";
                }

                if (weather.High - weather.Low > 20)
                {
                    weather.TempAdvisory += "Wear breathable layers! ";
                }

                weathers.Add(weather);
            }

            //this.weathersList = weathers;
            return(weathers);
        }
コード例 #28
0
        public override void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (Header != null)
            {
                ele.TryPathTo("Header", true, out subEle);
                Header.WriteXML(subEle, master);
            }
            if (ObjectList != null)
            {
                ele.TryPathTo("ObjectList", true, out subEle);
                ObjectList.WriteXML(subEle, master);
            }
            if (MapName != null)
            {
                ele.TryPathTo("MapName", true, out subEle);
                MapName.WriteXML(subEle, master);
            }
            if (GrassList != null)
            {
                ele.TryPathTo("GrassList", true, out subEle);
                GrassList.WriteXML(subEle, master);
            }
            if (MusicType != null)
            {
                ele.TryPathTo("MusicType", true, out subEle);
                MusicType.WriteXML(subEle, master);
            }
            if (Music != null)
            {
                ele.TryPathTo("Music", true, out subEle);
                Music.WriteXML(subEle, master);
            }
            if (IncidentalMediaSet != null)
            {
                ele.TryPathTo("MediaSet/Incidental", true, out subEle);
                IncidentalMediaSet.WriteXML(subEle, master);
            }
            if (BattleMediaSets != null)
            {
                ele.TryPathTo("MediaSet/Battle", true, out subEle);
                foreach (var entry in BattleMediaSets)
                {
                    XElement newEle = new XElement("MediaSet");
                    entry.WriteXML(newEle, master);
                    subEle.Add(newEle);
                }
            }
            if (Sounds != null)
            {
                ele.TryPathTo("Sounds", true, out subEle);
                Sounds.WriteXML(subEle, master);
            }
            if (Weathers != null)
            {
                ele.TryPathTo("Weathers", true, out subEle);
                Weathers.WriteXML(subEle, master);
            }
            if (Imposters != null)
            {
                ele.TryPathTo("Imposters", true, out subEle);
                Imposters.WriteXML(subEle, master);
            }
        }
コード例 #29
0
        public override void ReadBinary(ESPReader reader)
        {
            List <string> readTags = new List <string>();

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "RDAT":
                    if (readTags.Contains("RDAT"))
                    {
                        return;
                    }
                    Header.ReadBinary(reader);
                    break;

                case "RDOT":
                    if (readTags.Contains("RDOT"))
                    {
                        return;
                    }
                    if (ObjectList == null)
                    {
                        ObjectList = new RegionObjectList();
                    }

                    ObjectList.ReadBinary(reader);
                    break;

                case "RDMP":
                    if (readTags.Contains("RDMP"))
                    {
                        return;
                    }
                    if (MapName == null)
                    {
                        MapName = new SimpleSubrecord <String>();
                    }

                    MapName.ReadBinary(reader);
                    break;

                case "RDGS":
                    if (readTags.Contains("RDGS"))
                    {
                        return;
                    }
                    if (GrassList == null)
                    {
                        GrassList = new RegionGrassList();
                    }

                    GrassList.ReadBinary(reader);
                    break;

                case "RDMD":
                    if (readTags.Contains("RDMD"))
                    {
                        return;
                    }
                    if (MusicType == null)
                    {
                        MusicType = new SimpleSubrecord <RegionMusicType>();
                    }

                    MusicType.ReadBinary(reader);
                    break;

                case "RDMO":
                    if (readTags.Contains("RDMO"))
                    {
                        return;
                    }
                    if (Music == null)
                    {
                        Music = new RecordReference();
                    }

                    Music.ReadBinary(reader);
                    break;

                case "RDSI":
                    if (readTags.Contains("RDSI"))
                    {
                        return;
                    }
                    if (IncidentalMediaSet == null)
                    {
                        IncidentalMediaSet = new RecordReference();
                    }

                    IncidentalMediaSet.ReadBinary(reader);
                    break;

                case "RDSB":
                    if (BattleMediaSets == null)
                    {
                        BattleMediaSets = new List <RecordReference>();
                    }

                    RecordReference tempRDSB = new RecordReference();
                    tempRDSB.ReadBinary(reader);
                    BattleMediaSets.Add(tempRDSB);
                    break;

                case "RDSD":
                    if (readTags.Contains("RDSD"))
                    {
                        return;
                    }
                    if (Sounds == null)
                    {
                        Sounds = new RegionSoundList();
                    }

                    Sounds.ReadBinary(reader);
                    break;

                case "RDWT":
                    if (readTags.Contains("RDWT"))
                    {
                        return;
                    }
                    if (Weathers == null)
                    {
                        Weathers = new WeatherList();
                    }

                    Weathers.ReadBinary(reader);
                    break;

                case "RDID":
                    if (readTags.Contains("RDID"))
                    {
                        return;
                    }
                    if (Imposters == null)
                    {
                        Imposters = new FormArray();
                    }

                    Imposters.ReadBinary(reader);
                    break;

                default:
                    return;
                }

                readTags.Add(subTag);
            }
        }
コード例 #30
0
        public override void ReadXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("Header", false, out subEle))
            {
                if (Header == null)
                {
                    Header = new RegionDataHeader();
                }

                Header.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ObjectList", false, out subEle))
            {
                if (ObjectList == null)
                {
                    ObjectList = new RegionObjectList();
                }

                ObjectList.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("MapName", false, out subEle))
            {
                if (MapName == null)
                {
                    MapName = new SimpleSubrecord <String>();
                }

                MapName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("GrassList", false, out subEle))
            {
                if (GrassList == null)
                {
                    GrassList = new RegionGrassList();
                }

                GrassList.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("MusicType", false, out subEle))
            {
                if (MusicType == null)
                {
                    MusicType = new SimpleSubrecord <RegionMusicType>();
                }

                MusicType.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Music", false, out subEle))
            {
                if (Music == null)
                {
                    Music = new RecordReference();
                }

                Music.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("MediaSet/Incidental", false, out subEle))
            {
                if (IncidentalMediaSet == null)
                {
                    IncidentalMediaSet = new RecordReference();
                }

                IncidentalMediaSet.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("MediaSet/Battle", false, out subEle))
            {
                if (BattleMediaSets == null)
                {
                    BattleMediaSets = new List <RecordReference>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    RecordReference temp = new RecordReference();
                    temp.ReadXML(e, master);
                    BattleMediaSets.Add(temp);
                }
            }
            if (ele.TryPathTo("Sounds", false, out subEle))
            {
                if (Sounds == null)
                {
                    Sounds = new RegionSoundList();
                }

                Sounds.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Weathers", false, out subEle))
            {
                if (Weathers == null)
                {
                    Weathers = new WeatherList();
                }

                Weathers.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Imposters", false, out subEle))
            {
                if (Imposters == null)
                {
                    Imposters = new FormArray();
                }

                Imposters.ReadXML(subEle, master);
            }
        }