Пример #1
0
        internal void Materialized()
        {
            //check to see if LodgingForecasts.XML exists in memory
            if (_foreCastsXml == null)
            {
                if (System.IO.File.Exists("LodgingForecasts.XML"))
                {
                    //read the file with xelement - move code to application logic
                    _foreCastsXml = XElement.Load("LodgingForecasts.XML",
                                                  LoadOptions.None);
                }
                else
                {
                    throw new System.IO.FileNotFoundException
                              ("The LodgingForecasts.XML file was not found");
                }
            }
            string f = (from item in _foreCastsXml.Elements("Lodging")
                        where item.Attribute("ID").Value == LodgingID.ToString()
                        select item.Attribute("forecast").Value).FirstOrDefault();

            if (f != null)
            {
                TomorrowForecast = f;
            }
            else
            {
                TomorrowForecast = "";
            }
        }
Пример #2
0
 internal void Materialized()
 {
     //check to see if LodgingForecasts.XML exists
     if (System.IO.File.Exists("LodgingForecasts.XML"))
     {//read the file with xelement
         XElement file = XElement.Load("LodgingForecasts.XML",
                                       LoadOptions.None);
         string f = (from item in file.Elements("Lodging")
                     where item.Attribute("ID").Value == LodgingID.ToString()
                     select item.Attribute("forecast").Value).FirstOrDefault();
         if (f != null)
         {
             TomorrowForecast = f;
         }
         else
         {
             TomorrowForecast = "";
         }
     }
 }