Beispiel #1
0
 public ScoutInfo(HomeStoreScout hsScout) : this(hsScout.Name, hsScout.DllName)
 {
     if (!string.IsNullOrEmpty(hsScout.Version))
     {
         SetDesiredVersion(hsScout.Version);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Takes an xml node which describes a homestore scout and returns
        /// a HomeStoreScout structure
        /// </summary>
        /// <param name="xmlScout">the xml subtree of the app</param>
        /// <returns>The relevant HomeStoreScout structure</returns>
        private HomeStoreScout ReadHomeStoreScoutFromXml(Uri baseUri, XmlElement xmlScout)
        {
            if (!xmlScout.Name.Equals("Scout"))
            {
                throw new Exception("child is not a Scout in " + xmlScout);
            }

            HomeStoreScout homeStoreScout = new HomeStoreScout();

            homeStoreScout.Name        = xmlScout.GetAttribute("Name");
            homeStoreScout.DllName     = xmlScout.GetAttribute("DllName").Replace(".dll", "");
            homeStoreScout.Description = xmlScout.GetAttribute("Description");
            homeStoreScout.Rating      = int.Parse(xmlScout.GetAttribute("Rating"));

            homeStoreScout.IconUrl = null;
            try
            {
                string iconUrlString = xmlScout.GetAttribute("IconUrl");
                if (!String.IsNullOrWhiteSpace(iconUrlString))
                {
                    //this function does the right thing if iconUrlString is already absolute
                    homeStoreScout.IconUrl = new Uri(baseUri, iconUrlString).ToString();
                }
            }
            catch (Exception ex)
            {
                logger.Log("exception in parsing IconUrl for {0}: {1}", homeStoreScout.Name, ex.ToString());
            }

            homeStoreScout.Version = Constants.UnknownHomeOSUpdateVersionValue;
            try
            {
                string versionString = xmlScout.GetAttribute("Version");
                if (!String.IsNullOrWhiteSpace(versionString))
                {
                    homeStoreScout.Version = versionString;
                }
            }
            catch (Exception ex)
            {
                logger.Log("exception in parsing Version for {0}: {1}", homeStoreScout.Name, ex.ToString());
            }

            return(homeStoreScout);
        }
Beispiel #3
0
        public void ReadHomeStoreScouts(Uri fileName)
        {
            System.Net.WebRequest  req = System.Net.WebRequest.Create(fileName);
            System.Net.WebResponse resp;
            try
            {
                resp = req.GetResponse();
            }
            catch (System.Net.WebException)
            {
                logger.Log("error reading HomeStoreApps from {0}", fileName.ToString());
                return;
            }

            XmlDocument xmlDoc    = new XmlDocument();
            XmlReader   xmlReader = XmlReader.Create(resp.GetResponseStream(), xmlReaderSettings);

            xmlDoc.Load(xmlReader);
            XmlElement root = xmlDoc.FirstChild as XmlElement;

            if (!root.Name.Equals("Scouts"))
            {
                throw new Exception(fileName + " doesn't start with Scouts");
            }

            foreach (XmlElement xmlModule in root.ChildNodes)
            {
                try
                {
                    HomeStoreScout homeStoreScout = ReadHomeStoreScoutFromXml(fileName, xmlModule);
                    AddScoutToDB(homeStoreScout);
                }
                catch (Exception ex)
                {
                    logger.Log("Error reading/adding a home store app: " + ex.ToString());
                }
            }

            xmlReader.Close();
        }
Beispiel #4
0
 private void AddScoutToDB(HomeStoreScout scout)
 {
     scoutDb.Add(scout.Name, scout);
 }