Beispiel #1
0
        //homestore functions
        public void ReadHomeStoreApps(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("Modules"))
            {
                throw new Exception(fileName + " doesn't start with Modules");
            }

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

            xmlReader.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Takes an xml node which describes a homestore app and returns
        /// a HomeStoreApp structure
        /// </summary>
        /// <param name="xmlModule">the xml subtree of the app</param>
        /// <returns>The relevant HomeStoreApp structure</returns>
        private HomeStoreApp ReadHomeStoreAppFromXml(Uri baseUri, XmlElement xmlModule)
        {
            if (!xmlModule.Name.Equals("Module"))
            {
                throw new Exception("child is not a Module in " + xmlModule);
            }

            HomeStoreApp homeStoreApp = new HomeStoreApp();

            homeStoreApp.AppName     = xmlModule.GetAttribute("AppName");
            homeStoreApp.BinaryName  = xmlModule.GetAttribute("BinaryName");
            homeStoreApp.Description = xmlModule.GetAttribute("Description");
            homeStoreApp.Rating      = int.Parse(xmlModule.GetAttribute("Rating"));

            #region we don't have binary url anymore
            //try
            //{
            //    string binaryUrlString = xmlModule.GetAttribute("BinaryUrl");
            //    if (!String.IsNullOrWhiteSpace(binaryUrlString))
            //    {
            //        //this function does the right thing if binaryUrlString is already absolute
            //        homeStoreApp.BinaryUrl = new Uri(baseUri, binaryUrlString).ToString();
            //    }
            //    else
            //    {
            //        homeStoreApp.BinaryUrl = null;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    logger.Log("exception in parsing BinaryUrl for {0}: {1}", homeStoreApp.AppName, ex.ToString());
            //    homeStoreApp.BinaryUrl = null;
            //}
            #endregion

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

            homeStoreApp.Version = null;
            try
            {
                string versionString = xmlModule.GetAttribute("Version");
                if (!String.IsNullOrWhiteSpace(versionString))
                {
                    homeStoreApp.Version = versionString;
                }
            }
            catch (Exception ex)
            {
                logger.Log("exception in parsing Version for {0}: {1}", homeStoreApp.AppName, ex.ToString());
            }

            homeStoreApp.Manifest = ReadManifest(xmlModule, roleDb);

            //this field is filled in later
            homeStoreApp.CompatibleWithHome = false;

            return(homeStoreApp);
        }
Beispiel #3
0
 private void AddAppToDB(HomeStoreApp app)
 {
     moduleDb.Add(app.AppName, app);
 }