public void Deserialize(string str)
        {
            using (TextReader textReader = new StringReader(str))
            using (XmlReader xmlReader = new XmlTextReader(textReader))
            {
                xmlReader.ReadStartElement();

                xmlReader.ReadStartElement();
                this.Id = new Guid(xmlReader.ReadContentAsString());
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value1 = xmlReader.ReadContentAsInt();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value2 = xmlReader.ReadContentAsDateTime();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value3 = xmlReader.ReadContentAsString();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value4 = xmlReader.ReadContentAsDecimal();
                xmlReader.ReadEndElement();

                xmlReader.ReadEndElement();
            }
        }
        private static string ReadToValue(XmlTextReader reader)
        {
            while (reader.Read())
                if (reader.NodeType == XmlNodeType.Text)
                    break;

            return reader.ReadContentAsString();
        }
Esempio n. 3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     XmlTextReader TR = new XmlTextReader("C:\\Users\\u\\Visual Studio 2013\\ejLeerXML\\ejLeerXML\\definicion.xml"); //Crea un XmlTextReader abriendo el archivo
     string ultimaEtiqueta = ""; //cadena que almacena la ultima etiqueta
     while (TR.Read()) //ciclo mientras XmlTextReader está leendo
     {
         if (TR.NodeType == XmlNodeType.Element) //condicional cuando lee un tipo elemento
         {
             txtlectura.Text += (new String(' ', TR.Depth * 3) + "<" + TR.Name + ">");
             ultimaEtiqueta = TR.Name;
             continue;
         }
         if (TR.NodeType == XmlNodeType.Text) //condicional cuando lee un tipo texto
         {
             txtlectura.Text += TR.ReadContentAsString() + "</" + ultimaEtiqueta + ">";
         }
         else //de lo contrario, será un salto de línea
             txtlectura.Text += "\r";
     }
 }
Esempio n. 4
0
        public static DCompilerConfiguration LoadFromString(string xmlCode)
        {
            var cmp = new DCompilerConfiguration();

            var x = new XmlTextReader(new StringReader(xmlCode));

            if (x.ReadToFollowing("Compiler"))
            {
                if (x.MoveToAttribute("Name"))
                {
                    cmp.Vendor = x.ReadContentAsString();
                    x.MoveToElement();
                }

                cmp.ReadFrom(x);
            }

            x.Close();

            FitFileExtensions(cmp);

            return cmp;
        }
Esempio n. 5
0
        public static int ReadTextAsInt32(string elemName, XmlTextReader reader)
        {
            int retVal = -1;
             string tmpString = null;
             reader.Read();
             if(reader.NodeType != XmlNodeType.Text) {
            Console.WriteLine( "ReadTextAsInt32(): <" + elemName + ">: kein Text gefunden!" );

             } else {
            try {
               tmpString = reader.ReadContentAsString();
               retVal = Convert.ToInt32( tmpString );
            } catch(Exception ex) {
               try {
                  bool tryBool = Convert.ToBoolean( tmpString );
                  retVal = Convert.ToInt32( tryBool );
               } catch(Exception) {

               }
               if(retVal == -1) {
                  Console.WriteLine( "ReadTextAsInt32(): <" + elemName + ">: " + ex );
                  throw ex;
               }
            }
             }
             return retVal;
        }
Esempio n. 6
0
        private void ImportFiles(FileInfo f)
        {
            IndexList = new List<int>();
            GPXList = new List<GPXDatenSpeicher>();

            XmlTextReader xr = new XmlTextReader(f.FullName);
            #region Reader
            while (xr.Read())
            {
                if (Zustand == GPX_Zustände.START)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "gpx")
                    {
                        Zustand = GPX_Zustände.GPX;
                    }// ende if (xr.NodeType == XmlNodeType.Element && xr.Name == "gpx")
                }//ende if (Zustand == GPX_Zustände.START)
                else if (Zustand == GPX_Zustände.GPX)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "trk")
                    {
                        Zustand = GPX_Zustände.GPX_TRK;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "wpt")
                    {
                        if (xr.HasAttributes)
                        {
                            while (xr.MoveToNextAttribute())
                            {
                                if (xr.Name == "lat") akt_lat = xr.ReadContentAsDouble();
                                if (xr.Name == "lon") akt_lon = xr.ReadContentAsDouble();
                            }
                        }
                        Zustand = GPX_Zustände.GPX_WPT;
                    }// ende if (xr.NodeType == XmlNodeType.Element && xr.Name == "wpt")

                } // ende else if (Zustand == GPX_Zustände.GPX)
                else if (Zustand == GPX_Zustände.GPX_TRK)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_NAME;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "trkseg")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG;
                    }
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "trk")
                    {
                        Zustand = GPX_Zustände.GPX;
                    }
                }// ende else if (Zustand == GPX_Zustände.GPX_TRK)
                else if (Zustand == GPX_Zustände.GPX_WPT)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_ELE;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_NAME;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "cmt")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_CMT;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "desc")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_DESC;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "sym")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_SYM;
                    }
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "wpt")
                    {

                        SQL = "SELECT count(*) FROM tbl_Wegpunkt WHERE Längengrad like '" + akt_lon + "' AND Breitengrad like '" + akt_lat + "' AND Ele like '" + akt_ele + "' AND Name like '" + name + "' AND CMT like '" + cmt + "' AND DESC_Feld like '" + desc + "' AND sym like '" + sym + "'";
                        m.cmd = new OleDbCommand(SQL, m.con);
                        m.dr = m.cmd.ExecuteReader();
                        m.dr.Read();
                        if ((int)m.dr[0] == 0)
                        {
                            SQL = "INSERT INTO tbl_Wegpunkt (Längengrad,Breitengrad,Ele,Name,CMT,DESC_Feld,sym) VALUES ('" + akt_lon + "','" + akt_lat + "','" + akt_ele + "','" + name + "','" + cmt + "','" + desc + "','" + sym + "')";
                        }
                        m.cmd = new OleDbCommand(SQL, m.con);
                        m.cmd.ExecuteNonQuery();

                        Zustand = GPX_Zustände.GPX;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_ELE)
                {
                    strBuf = xr.ReadContentAsString().Replace('.', ',');
                    akt_ele = double.Parse(strBuf);
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_NAME)
                {
                    name = xr.ReadContentAsString();
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_CMT)
                {
                    cmt = xr.ReadContentAsString();
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "cmt")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_DESC)
                {
                    desc = xr.ReadContentAsString();
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "desc")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_SYM)
                {
                    sym = xr.ReadContentAsString();
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "sym")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_TRK_NAME)
                {
                    Track_Name = xr.ReadContentAsString();

                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_TRK;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_TRK_TRKSEG)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "trkpt")
                    {
                        if (xr.HasAttributes)
                        {
                            // Erst mal ALLE Attribute lesen!!
                            while (xr.MoveToNextAttribute())
                            {
                                if (xr.Name == "lat") akt_lat = xr.ReadContentAsDouble();
                                if (xr.Name == "lon") akt_lon = xr.ReadContentAsDouble();
                            }
                        }
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG_TRKPT;
                    }

                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "trkseg")
                    {
                        Zustand = GPX_Zustände.GPX_TRK;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_TRK_TRKSEG_TRKPT)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "time")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG_TRKPT_TIME;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG_TRKPT_ELE;
                    }
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "trkpt")
                    {
                        GPXList.Add(new GPXDatenSpeicher(akt_lat, akt_lon, akt_Zeit, akt_ele, Track_Name));
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_TRK_TRKSEG_TRKPT_TIME)
                {
                    akt_Zeit = xr.ReadContentAsString();
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "time")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG_TRKPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_TRK_TRKSEG_TRKPT_ELE)
                {
                    strBuf = xr.ReadContentAsString().Replace('.', ',');
                    akt_ele = double.Parse(strBuf);

                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG_TRKPT;
                    }
                }

            }//ende while (xr.Read())
            #endregion

            strBuf = null;
            //Noch wegpunkt einlesen einbauen... (keine lust)

            for (int i = 0; i < GPXList.Count; i++)
            {
                if (strBuf != GPXList[i].Name)
                {
                    IndexList.Add(i);
                }
                strBuf = GPXList[i].Name;
            }

            for (int iLoop = 0; iLoop < IndexList.Count; iLoop++)
            {
                EintragGefunden = false;
                if (!EintragGefunden)
                {
                    Min_Index = IndexList[iLoop];
                    EintragGefunden = CheckDataBase(GPXList[IndexList[iLoop]].Name, Min_Index);
                    if (iLoop == (IndexList.Count - 1))
                    {
                        Max_Index = GPXList.Count;
                    }
                    else
                    {
                        Max_Index = IndexList[iLoop + 1];
                    }
                }
                else
                {
                    //MessageBox.Show("Gibbet schon");
                }

                if (!EintragGefunden)
                {

                    SQL = "Insert Into tbl_track (Track_Name, Track_Name_Import) Values ('" + GPXList[IndexList[iLoop]].Name + "','" + GPXList[IndexList[iLoop]].Name + "')";
                    m.cmd = new OleDbCommand(SQL, m.con);
                    m.cmd.ExecuteNonQuery();

                    System.Threading.Thread.Sleep(100);
                    SQL = "Select ID_Track From tbl_track Where Track_Name_Import = '" + GPXList[IndexList[iLoop]].Name + "'";
                    m.cmd = new OleDbCommand(SQL, m.con);
                    m.dr = m.cmd.ExecuteReader();
                    m.dr.Read();
                    ID_Track_var = (int)m.dr[0];
                    //MessageBox.Show(m.dr[0].ToString());

                    for (int i = Min_Index; i < Max_Index; i++)
                    {

                        SQL = "Insert Into tbl_Trackpoint (Längengrad,Breitengrad,Zeit,Ele,FS_ID_Track) Values ('" + GPXList[i].Longitude + "','" + GPXList[i].Latitude + "','" + GPXList[i].Zeit + "','" + GPXList[i].Ele + "','" + ID_Track_var + "')";
                        m.cmd = new OleDbCommand(SQL, m.con);
                        m.cmd.ExecuteNonQuery();

                    }

                    //MessageBox.Show("is drin" + debug.ToString());
                }
                else
                {
                    //MessageBox.Show("is schon drin" + debug.ToString());
                }

            }
        }
Esempio n. 7
0
        /* Read all el 2a7dees al nabawaya and fill the treeview */
        private void LoadHadeethTree()
        {
            /* Check first if the tree was already loaded*/
            if (trvHadeeth.Nodes.Count > 0) return;

            XmlTextReader xmlReader;
            TreeNode rNode, bNode;

            for (int i = 0; i < 6; i++) {

                /* Check if the file exists first*/
                if (!File.Exists(hadeeth_xml[i])) continue;
                xmlReader = new XmlTextReader(hadeeth_xml[i]);
                xmlReader.ReadToFollowing("kotob");
                rNode = new TreeNode(xmlReader.GetAttribute(0));

                xmlReader.ReadToFollowing("katab");
                do {
                    xmlReader.MoveToFirstAttribute();
                    bNode = new TreeNode(xmlReader.ReadContentAsString());
                    xmlReader.MoveToElement();
                    if (xmlReader.ReadToDescendant("bab")) {
                        /* iterate through el babs in el katab if there are any */
                        do {
                            xmlReader.MoveToAttribute(0);
                            bNode.Nodes.Add(xmlReader.ReadContentAsString());
                        } while (xmlReader.ReadToNextSibling("bab"));
                    }
                    rNode.Nodes.Add(bNode);
                } while (xmlReader.ReadToFollowing("katab"));

                trvHadeeth.Nodes.Add(rNode);

            }
        }
Esempio n. 8
0
		/// <summary>
		/// Parses the Log config file and extracts all archived logs.
		/// </summary>
		/// <returns>A Queue made of strings containing logs urls.</returns>
		public static Queue GetArchivedLogsUrls()
		{
			FileInfo info = new FileInfo(GameServer.Instance.Configuration.LogConfigFile);
			Queue dirList = new Queue();

			try
			{
				if (info.Exists)
				{
					Queue archiveList = new Queue(); // List made of all archived logs urls.

					// We parse the xml file to find urls of logs.
					XmlTextReader configFileReader = new XmlTextReader(info.OpenRead());
					configFileReader.WhitespaceHandling = WhitespaceHandling.None;
					while (configFileReader.Read())
					{
						if (configFileReader.LocalName == "file")
						{
							// First attribute of node file is the url of a Log.
							configFileReader.MoveToFirstAttribute();
							info = new FileInfo(configFileReader.ReadContentAsString());

							// Foreach file in the Log directory, we will return all logs with
							// the same name + an extension added when archived.
							foreach (string file in Directory.GetFiles(info.DirectoryName, info.Name + "*"))
							{
								// Only if this file is accessible we add it to the list we will return.
								if (file != info.FullName)
									archiveList.Enqueue(file);
							}
						}
					}
					return archiveList;
				}
				else
				{
					// We return the default value.
					Queue archiveList = new Queue(); // List made of all archived logs urls.
					archiveList.Enqueue("./logs/Cheats.Log");
					archiveList.Enqueue("./logs/GMActions.Log");
					archiveList.Enqueue("./logs/Error.Log");
					archiveList.Enqueue("./logs/GameServer.Log");
					return archiveList;
				}
			}
			catch (Exception e)
			{
				Logger.Error(e);
				return dirList;
			}
		}
        //Read Program - This method must be refactored into DataSample
        private void ReadXMLProgram()
        {
            CurrentVO2MaxProgram = new VO2MaxProgram();
            string RootDiretory = AppDomain.CurrentDomain.BaseDirectory;
            XmlTextReader reader = null;

            switch (DataSample.ProgramSelector)
            {
                case Enumerators.ProgramSelect.VO2MaxProgram1:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram1.xml");
                    lblTitle.Text = "Program: VO2 Max Program 1";
                    lblDescription.Text = "Program Time: 30 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram1PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram2:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram2.xml");
                    lblTitle.Text = "Program: VO2 Max Program 2";
                    lblDescription.Text = "Program Time: 30 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram2PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram3:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram3.xml");
                    lblTitle.Text = "Program: VO2 Max Program 3";
                    lblDescription.Text = "Program Time: 26 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram3PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram4:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram4.xml");
                    lblTitle.Text = "Program: VO2 Max Program 4";
                    lblDescription.Text = "Program Time: 20 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram4PB;
                    break;
                case Enumerators.ProgramSelect.CPM:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\CPMProgram.xml");
                    lblTitle.Text = "Program: Continuous Passive Motion (CPM)";
                    lblDescription.Text = "Program Time: 20 min";
                    CurrentPowerIndex = GlobalVariables.CPMProgramPB;
                    break;
                case Enumerators.ProgramSelect.Proprioception:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProprioceptionProgram.xml");
                    lblTitle.Text = "Program: Proprioception";
                    lblDescription.Text = "Program Time: 10 min";
                    CurrentPowerIndex = GlobalVariables.PropriocenptionProgramPB;
                    break;
                case Enumerators.ProgramSelect.RehabBilateral:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml");
                    lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramPB;
                    break;
                case Enumerators.ProgramSelect.RehabLeftLeg:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabLeftLeg.xml");
                    lblTitle.Text = "Program: Rehabilitation - Left Leg (11 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramLeftPB;
                    break;
                case Enumerators.ProgramSelect.RehabRightLeg:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabRightLeg.xml");
                    lblTitle.Text = "Program: Rehabilitation - Right Leg (11 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramRightPB;
                    break;
                //case Enumerators.ProgramSelect.CustomProgram:
                //    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml");
                //    lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)";
                //    lblDescription.Text = "Program Time: 15 min";
                //    CurrentPowerIndex = GlobalVariables.RehabProgramPB;
                //    break;
                default:
                    break;
            }

            while (reader.Read())
            {
                if (reader.ReadToFollowing("StageIndex"))
                {
                    VO2MaxStage newVO2MaxStage = new VO2MaxStage();
                    reader.Read();
                    newVO2MaxStage.StageIndex = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageNumber");
                    reader.Read();
                    newVO2MaxStage.StageNumber = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageName");
                    reader.Read();
                    newVO2MaxStage.StageName = reader.ReadContentAsString();
                    reader.ReadToFollowing("StageDuration");
                    reader.Read();
                    newVO2MaxStage.StageTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                    reader.ReadToFollowing("Sets");
                    reader.Read();

                    while (reader.Read())
                    {
                        if (reader.Name == "Set")
                        {
                            VO2MaxSet newVO2MaxSet = new VO2MaxSet();
                            reader.ReadToFollowing("SetIndex");
                            reader.Read();
                            newVO2MaxSet.SetIndex = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Number");
                            reader.Read();
                            newVO2MaxSet.SetNumber = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Duration");
                            reader.Read();
                            double SetTime = reader.ReadContentAsDouble();
                            if (SetTime < 1)
                            {
                                SetTime = SetTime * 60;
                                newVO2MaxSet.TimeRemaining = new TimeSpan(0, 0, Convert.ToInt32(SetTime));
                            }
                            else
                            {
                                newVO2MaxSet.TimeRemaining = new TimeSpan(0, Convert.ToInt32(SetTime), 0);
                            }
                            reader.ReadToFollowing("Direction");
                            reader.Read();
                            newVO2MaxSet.Direction = reader.ReadContentAsString();
                            reader.ReadToFollowing("DirectionFlag");
                            reader.Read();
                            int DirectionVariable = reader.ReadContentAsInt();
                            if (DirectionVariable == 1)
                                newVO2MaxSet.SelectedDirection = Enumerators.Direction.Forward;
                            else if (DirectionVariable == -1)
                                newVO2MaxSet.SelectedDirection = Enumerators.Direction.Backward;
                            reader.ReadToFollowing("Contraction");
                            reader.Read();
                            newVO2MaxSet.Contraction = reader.ReadContentAsString();
                            reader.ReadToFollowing("Legs");
                            reader.Read();
                            newVO2MaxSet.Legs = reader.ReadContentAsString();
                            reader.ReadToFollowing("Position");
                            reader.Read();
                            newVO2MaxSet.Position = reader.ReadContentAsString();
                            reader.ReadToFollowing("RestDuration");
                            reader.Read();
                            newVO2MaxSet.RestTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                            reader.ReadToFollowing("Instructions");
                            reader.Read();
                            newVO2MaxSet.Instructions = reader.ReadContentAsString();
                            newVO2MaxStage.VO2MaxSetCollection.Add(newVO2MaxSet);

                            reader.Read();  //Read White Space
                            reader.Read();  //Read Set
                            reader.Read();  //Read White Space

                        }
                        else
                        {
                            break;
                        }
                    }
                    CurrentVO2MaxProgram.VO2MaxStageCollection.Add(newVO2MaxStage);
                }
            }

            CurrentVO2MaxProgram.ProgramTime = new TimeSpan(0, 0, 0);
            foreach (VO2MaxStage stage in CurrentVO2MaxProgram.VO2MaxStageCollection)
            {
                CurrentVO2MaxProgram.ProgramTime = CurrentVO2MaxProgram.ProgramTime + stage.StageTimeRemaining;
            }
        }
        // Загрузка всех сборок.
        public override List<ResultAssembly> LoadAllAssemblies()
        {
            List<ResultAssembly> assemblies = new List<ResultAssembly>();
            ResultAssembly assembly = null;

            foreach (string file in Directory.GetFiles(directory, "*.xml",
                SearchOption.TopDirectoryOnly))
            {
                assembly = new ResultAssembly();
                assemblies.Add(assembly);
                using (XmlTextReader reader = new XmlTextReader(file))
                {
                    try
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                if (reader.Name == "id")
                                {
                                    assembly.ID = new Guid(reader.ReadElementString());
                                }
                                if (reader.Name == "name")
                                {
                                    assembly.Name = reader.ReadElementString();
                                }
                                if (reader.Name == "graphmodel")
                                {
                                    reader.MoveToAttribute("modelname");
                                    assembly.ModelName = reader.ReadContentAsString();
                                    break;
                                }
                                // !исправить!
                            }
                        }
                    }
                    catch (SystemException)
                    {
                        continue;
                    }
                }
            }

            return assemblies;
        }
        /// <summary>
        /// Load data cached in aarExplodeDataFile into aarExplodeData.
        /// </summary>
        private void LoadAarExplodeCache()
        {
            if (!File.Exists(aarExplodeDataFile)) return;

            XmlTextReader reader = new XmlTextReader(new StreamReader(aarExplodeDataFile));
            aarExplodeData.Clear();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "aars")
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "explodeData")
                        {
                            string aar = "";
                            AarExplodeData aarData = new AarExplodeData();
                            do
                            {
                                if (!reader.Read()) break;
                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    string elementName = reader.Name;
                                    if (reader.Read() && reader.NodeType == XmlNodeType.Text)
                                    {
                                        if (elementName == "aar")
                                        {
                                            aar = reader.ReadContentAsString();
                                        }
                                        else if (elementName == "modificationTime")
                                        {
                                            aarData.modificationTime =
                                                reader.ReadContentAsDateTime();
                                        }
                                        else if (elementName == "explode")
                                        {
                                            aarData.explode = reader.ReadContentAsBoolean();
                                        }
                                        else if (elementName == "bundleId")
                                        {
                                            aarData.bundleId = reader.ReadContentAsString();
                                        }
                                        else if (elementName == "path")
                                        {
                                            aarData.path = reader.ReadContentAsString();
                                        }
                                    }
                                }
                            } while (!(reader.Name == "explodeData" &&
                                       reader.NodeType == XmlNodeType.EndElement));
                            if (aar != "") aarExplodeData[aar] = aarData;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
		public static SystemConfig LoadFromXml(Stream stream, bool isEncrypted)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream");
			}

			using (XmlTextReader reader = new XmlTextReader(stream))
			{
				if (reader != null)
				{
					SystemConfig config = new SystemConfig();
					while (reader.Read())
					{
						if (reader.NodeType == XmlNodeType.Element && reader.Name == XmlElementConfig)
						{
							reader.MoveToAttribute(XmlAttribute);
							string attribute = reader.ReadContentAsString();
							switch (attribute)
							{
								case "MaxConnectionCount":
									reader.MoveToAttribute(XmlValue);
									config._maxConnectionCount = (ushort)reader.ReadContentAsInt();
									break;
                                case "AdminServerListenIP":
                                    reader.MoveToAttribute(XmlValue);
                                    config._adminServerListenIP = reader.ReadContentAsString();
                                    break;
								case "AdminServerListenPort":
									reader.MoveToAttribute(XmlValue);
									config._adminServerListenPort = reader.ReadContentAsInt();
									break;                                
								case "SecondaryAdminServerListenPort":
									reader.MoveToAttribute(XmlValue);
									config._secondaryAdminServerListenPort = reader.ReadContentAsInt();
									break;
								case "AdminServerUploadFileRootPath":
									reader.MoveToAttribute(XmlValue);
									config._adminServerUploadFileRootPath = reader.ReadContentAsString();

                                    if (!config._adminServerUploadFileRootPath.EndsWith(@"\")) config._adminServerUploadFileRootPath += @"\";

                                    //若该文件夹不存在,则创建它
                                    if (Directory.Exists(config._adminServerUploadFileRootPath) == false)
                                    {
                                        Directory.CreateDirectory(config._adminServerUploadFileRootPath);
                                    }

									break;
								case "DbConnectionString":
									{
										reader.MoveToAttribute(XmlValue);
										string readConnectionString = reader.ReadContentAsString();
										if (isEncrypted)
										{
											try
											{
												config._dbConnectionString = CryptographyManager.TheInstance.PredefinedDecrypt(readConnectionString, Encoding.Default);
											}
											catch (Exception ex)
											{
												throw new Exception("Decrypt SystemConfig Entry \"DbConnectionString\" Failed.", ex);
											}
										}
										else
										{
											config._dbConnectionString = readConnectionString;
										}
									}
									break;
								case "DefaultDbName":
									reader.MoveToAttribute(XmlValue);
									config._defaultDbName = reader.ReadContentAsString();
									break;
								case "DefaultEncoding":
									reader.MoveToAttribute(XmlValue);
									config._defaultEncoding = Encoding.GetEncoding(reader.ReadContentAsString());
									break;
								case "DefaultNewLine":
									{
										reader.MoveToAttribute(XmlValue);
										string newLine = reader.ReadContentAsString();
										if (newLine == @"\n")
										{
											config._defaultNewLine = "\n";
										}
										else if (newLine == @"\r\n")
										{
											config._defaultNewLine = "\r\n";
										}
									}
									break;
								case "LogDir":
									reader.MoveToAttribute(XmlValue);
									config._logDir = reader.ReadContentAsString();

                                    if (!config._logDir.EndsWith(@"\")) config._logDir+=@"\";

                                    //若该文件夹不存在,则创建它
                                    if (Directory.Exists(config._logDir) == false)
                                    {
                                        Directory.CreateDirectory(config._logDir);
                                    }

									break;
								case "LogEnabled":
									reader.MoveToAttribute(XmlValue);
									config._logEnabled = reader.ReadContentAsBoolean();
									break;
								case "ListenForConfigGuardReturnPort":
									reader.MoveToAttribute(XmlValue);
									config._listenForConfigGuardReturnPort = reader.ReadContentAsInt();
									break;
								case "ConfigGuardPort":
									reader.MoveToAttribute(XmlValue);
									config._configGuardPort = reader.ReadContentAsInt();
									break;
								case "NeedGuardAuthorization":
									reader.MoveToAttribute(XmlValue);
									config._needGuardAuthorization = reader.ReadContentAsBoolean();
									break;
								case "GameSettingDir":
									reader.MoveToAttribute(XmlValue);
                                    config._gameSettingDir = reader.ReadContentAsString();

                                    if (!config._gameSettingDir.EndsWith(@"\")) config._gameSettingDir += @"\";

                                    //若该文件夹不存在,则创建它
                                    if (Directory.Exists(config._gameSettingDir) == false)
                                    {
                                        Directory.CreateDirectory(config._gameSettingDir);
                                    }
									
									break;
								case "GuardAuthorizationTimeout":
									reader.MoveToAttribute(XmlValue);
									config._guardAuthorizationTimeout = reader.ReadContentAsLong();
									break;
                                case "EnablePaysys":
                                    reader.MoveToAttribute(XmlValue);
                                    config._enablePaysys = reader.ReadContentAsBoolean();
                                    break;
                                case "DBDefaultIP":
                                    reader.MoveToAttribute(XmlValue);
                                    config.dbDefaultIP = reader.ReadContentAsString();
                                    break;
                                case "DefaultGameDbName":
                                    reader.MoveToAttribute(XmlValue);
                                    config.defaultGameDbName = reader.ReadContentAsString();
                                    break;
								case "PaySysDbConnectionString":
									{
										reader.MoveToAttribute(XmlValue);
										string readConnectionString = reader.ReadContentAsString();
                                        if (config._enablePaysys)
                                        {
                                            if (isEncrypted)
                                            {
                                                try
                                                {
                                                    config._paySysDbConnectionString = CryptographyManager.TheInstance.PredefinedDecrypt(readConnectionString, Encoding.Default);
                                                }
                                                catch (Exception ex)
                                                {
                                                    throw new Exception("Decrypt SystemConfig Entry \"PaySysDbConnectionString\" Failed.", ex);
                                                }
                                            }
                                            else
                                            {
                                                config._paySysDbConnectionString = readConnectionString;
                                            }
                                        }										
									}
									break;
								case "PreloadGameData":
									reader.MoveToAttribute(XmlValue);
									config._preloadGameData = reader.ReadContentAsBoolean();
									break;
                                case "ServerListFileDir":
                                    reader.MoveToAttribute(XmlValue);
                                    config._serverListFileDir = reader.ReadContentAsString();
                                    
                                    if (!config._serverListFileDir.EndsWith(@"\")) config._serverListFileDir += @"\";

                                    //若该文件夹不存在,则创建它
                                    if (Directory.Exists(config._serverListFileDir) == false)
                                    {
                                        Directory.CreateDirectory(config._serverListFileDir);
                                    }

                                    break;
                                case "ServerListFileName":
                                    reader.MoveToAttribute(XmlValue);
                                    config._serverListFileName = reader.ReadContentAsString();
                                    break;
                                case "PakFileName":
                                    reader.MoveToAttribute(XmlValue);
                                    config._pakFileName = reader.ReadContentAsString();
                                    break;
                                case "ServerListCRCFileName":
                                    reader.MoveToAttribute(XmlValue);
                                    config._serverListCRCFileName = reader.ReadContentAsString();
                                    break;
                                case "ServerListServerGroupMaxPlayer":
                                    reader.MoveToAttribute(XmlValue);
                                    config._serverListServerGroupMaxPlayer = reader.ReadContentAsInt();
                                    break;
                                case "SMSUrl":
                                    reader.MoveToAttribute(XmlValue);
                                    config._smsUrl = reader.ReadContentAsString();
                                    break;
                                case "SMSCommand":
                                    reader.MoveToAttribute(XmlValue);
                                    config._smsCommand = reader.ReadContentAsString();
                                    break;
                                case "WebSiteVersion":
                                    reader.MoveToAttribute(XmlValue);
                                    config.websiteVersion = reader.ReadContentAsString();
                                    break;
                                case "GroupPlayerCountDir":
                                    reader.MoveToAttribute(XmlValue);
                                    config._groupPlayerCountDir = reader.ReadContentAsString();
                                    if (!config._groupPlayerCountDir.EndsWith(@"\")) config._groupPlayerCountDir += @"\";

                                    //若该文件夹不存在,则创建它
                                    if (Directory.Exists(config._groupPlayerCountDir) == false)
                                    {
                                        Directory.CreateDirectory(config._groupPlayerCountDir);
                                    }
                                    break;
                                case "GroupPlayerCountFileName":
                                    reader.MoveToAttribute(XmlValue);
                                    config._groupPlayerCountFileName = reader.ReadContentAsString();
                                    break;
                                case "GroupPlayerCountKickInterval":
                                    reader.MoveToAttribute(XmlValue);
                                    config._groupPlayerCountKickInterval = reader.ReadContentAsInt();
                                    break;
								default:
									throw new Exception("Unknown attribute '" + attribute + "' found in xml stream.");
							}
						}
					}
					return config;
				}
			}

			return null;
		}
        public static Element ParseXML(Stream xmlStream)
        {
            StreamReader textReader = new StreamReader(xmlStream);
            string responseString = "";
            while (!textReader.EndOfStream)
                responseString += textReader.ReadLine();

            StringReader stringReader = new StringReader(responseString);
            
            XmlTextReader reader = new XmlTextReader(stringReader);

#if DEBUG
            Console.Out.WriteLine("Original XML:");
            responseString = responseString.Replace(">", ">\n");
            Console.Out.WriteLine(responseString);
            Console.Out.WriteLine("");
#endif
            Element rootNode = new Element();
            rootNode.IsRootNode = true;
            //int lastDepth = -1;
            try
            {
                Stack<Element> stack = new Stack<Element>();
                
                stack.Push(rootNode);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            Element newElement = new Element();
                            newElement.Name = reader.Name;
                            newElement.Parent = stack.Peek();
                            stack.Peek().AddChildElement(newElement);
                            while (reader.MoveToNextAttribute())
                            {
                                Libellus.XML.Attribute a = new Libellus.XML.Attribute();
                                a.Name = reader.Name;
                                a.Value = reader.ReadContentAsString();
                                newElement.Attributes.Add(a);
                            }
                            if(!newElement.Name.Equals("Price"))
                                stack.Push(newElement);

                            break;

                        case XmlNodeType.Text:
                            stack.Peek().Value = reader.Value;
                            break;

                        case XmlNodeType.EndElement:
                            stack.Pop();
                            break;

                       
                    }
                }

                
            }
            catch (Exception e1)
            {
                ExceptionHandler.HandleException(e1);
            }

            return rootNode;
        }
        //Read Program
        public ProgramData ReadXMLProgram()
        {
            ProgramData CurrentProgram = new ProgramData();
            string RootDiretory = AppDomain.CurrentDomain.BaseDirectory;
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            XmlTextReader reader = null;

            switch (this.ProgramSelector)
            {
                case Enumerators.ProgramSelect.FTPTest:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\FTPTestConcentric.xml");
                    break;
                case Enumerators.ProgramSelect.VO2MaxTest:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxTest.xml");
                    break;
                default:
                    break;
            }

            while (reader.Read())
            {
                if (reader.ReadToFollowing("StageIndex"))
                {
                    ProgramStage newFTPStage = new ProgramStage();
                    reader.Read();
                    newFTPStage.StageIndex = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageNumber");
                    reader.Read();
                    newFTPStage.StageNumber = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageName");
                    reader.Read();
                    newFTPStage.StageName = reader.ReadContentAsString();
                    reader.ReadToFollowing("StageDuration");
                    reader.Read();
                    newFTPStage.StageTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                    reader.ReadToFollowing("Sets");
                    reader.Read();

                    while (reader.Read())
                    {
                        if (reader.Name == "Set")
                        {
                            ProgramSet newFTPSet = new ProgramSet();
                            reader.ReadToFollowing("SetIndex");
                            reader.Read();
                            newFTPSet.SetIndex = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Number");
                            reader.Read();
                            newFTPSet.SetNumber = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Duration");
                            reader.Read();
                            newFTPSet.TimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                            reader.ReadToFollowing("Direction");
                            reader.Read();
                            newFTPSet.Direction = reader.ReadContentAsString();
                            reader.ReadToFollowing("DirectionFlag");
                            reader.Read();
                            int DirectionVariable = reader.ReadContentAsInt();
                            if (DirectionVariable == 1)
                                newFTPSet.SelectedDirection = Enumerators.Direction.Forward;
                            else if (DirectionVariable == -1)
                                newFTPSet.SelectedDirection = Enumerators.Direction.Backward;
                            reader.ReadToFollowing("Contraction");
                            reader.Read();
                            newFTPSet.Contraction = reader.ReadContentAsString();
                            reader.ReadToFollowing("Legs");
                            reader.Read();
                            newFTPSet.Legs = reader.ReadContentAsString();
                            reader.ReadToFollowing("Position");
                            reader.Read();
                            newFTPSet.Position = reader.ReadContentAsString();
                            reader.ReadToFollowing("RestDuration");
                            reader.Read();
                            newFTPSet.RestTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                            reader.ReadToFollowing("Instructions");
                            reader.Read();
                            newFTPSet.Instructions = reader.ReadContentAsString();
                            newFTPStage.FTPSetConcentricCollection.Add(newFTPSet);

                            reader.Read();  //Read White Space
                            reader.Read();  //Read Set
                            reader.Read();  //Read White Space

                        }
                        else
                        {
                            break;
                        }
                    }
                    CurrentProgram.FTPStageCollection.Add(newFTPStage);
                }
            }

            CurrentProgram.CurrentFTPStage = CurrentProgram.FTPStageCollection[0];
            CurrentProgram.CurrentFTPStage.CurrentFTPSet = CurrentProgram.CurrentFTPStage.FTPSetConcentricCollection[0];
            return CurrentProgram;
        }
 public string getChosenElement(XmlTextReader xml, string element)
 {
     string content;
     try
     {
         xml.ReadStartElement(element);
         content = xml.ReadContentAsString();
         xml.ReadEndElement();
     }
     catch (XmlException e)
     {
         content = null;
     }
     return content;
 }
Esempio n. 16
0
        internal void Deserialize(XmlTextReader reader)
        {
            bool keepreading = true;
            while (keepreading)
            {
                reader.Read();
                if (reader.Name.Equals("material") && reader.NodeType.Equals(XmlNodeType.Element))
                {
                    VoxMaterial mat = new VoxMaterial();
                    mat.ID = (byte)reader.ReadContentAsInt();
                    mat.Name = reader.ReadContentAsString();
                    mat.Flags = (MatFlags)Enum.Parse(typeof(MatFlags), reader.ReadContentAsString());
                    mat.Density = reader.ReadContentAsFloat();
                    mat.Deposit = (DepositType)Enum.Parse(typeof(DepositType), reader.ReadContentAsString());
                    mat.Texture = UUID.Parse(reader.ReadContentAsString());
                    mat.Type = (MaterialType)Enum.Parse(typeof(MaterialType), reader.ReadContentAsString());

                    if (mat.ID > index)
                    {
                        index = mat.ID;
                        index++;
                    }

                    mMaterials.Add(mat.ID, mat);
                    mName2Byte.Add(mat.Name, mat.ID);
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Decrpyts a security token from an XML EncryptedData 
        /// </summary>
        /// <param name="xmlToken">the XML token to decrypt</param>
        /// <returns>A byte array of the contents of the encrypted token</returns>
        private static byte[] decryptToken(string xmlToken)
        {
            int encryptionAlgorithm;
            int m_keyEncryptionAlgorithm;
            string m_keyHashAlgorithm;
            byte[] thumbprint;
            byte[] securityTokenData;
            byte[] symmetricKeyData;

            XmlReader reader = new XmlTextReader(new StringReader(xmlToken));

            // Find the EncryptionMethod element, grab the Algorithm
            if (!reader.ReadToDescendant(XmlEncryptionStrings.EncryptionMethod, XmlEncryptionStrings.Namespace))
                throw new ArgumentException("Cannot find token EncryptedMethod.");
            encryptionAlgorithm = reader.GetAttribute(XmlEncryptionStrings.Algorithm).GetHashCode();

            // Find the EncryptionMethod element for the key, grab the Algorithm
            if (!reader.ReadToFollowing(XmlEncryptionStrings.EncryptionMethod, XmlEncryptionStrings.Namespace))
                throw new ArgumentException("Cannot find key EncryptedMethod.");
            m_keyEncryptionAlgorithm = reader.GetAttribute(XmlEncryptionStrings.Algorithm).GetHashCode();

            // Find the Digest method for the key identifier
            if (!reader.ReadToFollowing(XmlSignatureStrings.DigestMethod, XmlSignatureStrings.Namespace))
                throw new ArgumentException("Cannot find Digest Method.");
            m_keyHashAlgorithm = reader.GetAttribute(XmlEncryptionStrings.Algorithm);
            // Find the key identifier
            if (!reader.ReadToFollowing(WSSecurityStrings.KeyIdentifier, WSSecurityStrings.Namespace))
                throw new ArgumentException("Cannot find Key Identifier.");
            reader.Read();
            thumbprint = Convert.FromBase64String(reader.ReadContentAsString());

            // Find the encrypted Symmetric Key
            if (!reader.ReadToFollowing(XmlEncryptionStrings.CipherValue, XmlEncryptionStrings.Namespace))
                throw new ArgumentException("Cannot find symmetric key.");
            reader.Read();
            symmetricKeyData = Convert.FromBase64String(reader.ReadContentAsString());

            // Find the encrypted Security Token
            if (!reader.ReadToFollowing(XmlEncryptionStrings.CipherValue, XmlEncryptionStrings.Namespace))
                throw new ArgumentException("Cannot find encrypted security token.");
            reader.Read();
            securityTokenData = Convert.FromBase64String(reader.ReadContentAsString());

            reader.Close();

            SymmetricAlgorithm alg = null;
            X509Certificate2 certificate = FindCertificate(thumbprint);

            foreach (int i in Aes)
                if (encryptionAlgorithm == i)
                {
                    alg = new RijndaelManaged();
                    break;
                }
            if (null == alg)
                foreach (int i in TripleDes)
                    if (encryptionAlgorithm == i)
                    {
                        alg = new TripleDESCryptoServiceProvider();
                        break;
                    }

            if (null == alg)
                throw new ArgumentException("Could not determine Symmetric Algorithm");
            alg.Key = (certificate.PrivateKey as RSACryptoServiceProvider).Decrypt(symmetricKeyData, true); ;
            int ivSize = alg.BlockSize / 8;
            byte[] iv = new byte[ivSize];
            Buffer.BlockCopy(securityTokenData, 0, iv, 0, iv.Length);
            alg.Padding = PaddingMode.ISO10126;
            alg.Mode = CipherMode.CBC;
            ICryptoTransform decrTransform = alg.CreateDecryptor(alg.Key, iv);
            byte[] plainText = decrTransform.TransformFinalBlock(securityTokenData, iv.Length, securityTokenData.Length - iv.Length);
            decrTransform.Dispose();
            return plainText;
        }
        private bool HandleImportDialog (ItunesImportDialog dialog, ImportDialogHandler code)
        {
            try {
                if (dialog.Run () == (int)ResponseType.Ok) {
                    if(code != null) {
                        code (dialog);
                    }
                    data.get_ratings = dialog.Ratings;
                    data.get_stats = dialog.Stats;
                    data.get_playlists = dialog.Playliststs;
                } else {
                    return false;
                }
            } finally {
                dialog.Destroy ();
                dialog.Dispose ();
            }

            if (String.IsNullOrEmpty (data.library_uri)) {
                return false;
            }

            // Make sure the library version is supported (version 1.1)
            string message = null;
            bool prompt = false;
            using (var xml_reader = new XmlTextReader (data.library_uri))
            {
                xml_reader.ReadToFollowing ("key");
                do {
                    xml_reader.Read ();
                    string key = xml_reader.ReadContentAsString ();
                    if (key == "Major Version" || key == "Minor Version") {
                        xml_reader.Read ();
                        xml_reader.Read ();
                        if(xml_reader.ReadContentAsString () != "1") {
                            message = Catalog.GetString (
                                "Banshee is not familiar with this version of the iTunes library format." +
                                " Importing may or may not work as expected, or at all. Would you like to attempt to import anyway?");
                            prompt = true;
                            break;
                        }
                    }
                } while (xml_reader.ReadToNextSibling ("key"));
            }

            if (prompt) {
                bool proceed = false;
                using (var message_dialog = new MessageDialog (null, 0, MessageType.Question, ButtonsType.YesNo, message)) {
                    if (message_dialog.Run () == (int)ResponseType.Yes) {
                        proceed = true;
                    }
                    message_dialog.Destroy ();
                }
                if (!proceed) {
                    LogError (data.library_uri, "Unsupported version");
                    return false;
                }
            }

            return true;
        }