/// <summary>
 ///     Reads this instance.
 /// </summary>
 public List<XmlExceptionParser> Read(string exceptionPath)
 {
     var exceptionsList = new List<XmlExceptionParser>();
     var xmlText = new XmlTextReader(exceptionPath);
     while (xmlText.Read())
     {
         var xmlNode = new XmlExceptionParser();
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Message")
         {
             xmlNode.Message = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Source")
         {
             xmlNode.Source = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Stack")
         {
             xmlNode.Stack = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Date")
         {
             xmlNode.Date = Convert.ToDateTime(xmlText.ReadElementString());
         }
         if (!string.IsNullOrEmpty(xmlNode.Message) && !string.IsNullOrEmpty(xmlNode.Source) &&
             !string.IsNullOrEmpty(xmlNode.Stack))
         {
             exceptionsList.Add(xmlNode);
         }
     }
     xmlText.Close();
     return exceptionsList;
 }
        public static AAInventoryItemBase Deserialize(string serialization)
        {
            AAInventoryItemBase item = new AAInventoryItemBase();

            StringReader sr = new StringReader(serialization);
            XmlTextReader xtr = new XmlTextReader(sr);

            xtr.ReadStartElement("InventoryItem");

            item.Name = xtr.ReadElementString("Name");
            item.ID = UUID.Parse(xtr.ReadElementString("ID"));
            item.InvType = Convert.ToInt32(xtr.ReadElementString("InvType"));
            item.CreatorId = xtr.ReadElementString("CreatorUUID");
            item.CreationDate = Convert.ToInt32(xtr.ReadElementString("CreationDate"));
            item.Owner = UUID.Parse(xtr.ReadElementString("Owner"));
            item.Description = xtr.ReadElementString("Description");
            item.AssetType = Convert.ToInt32(xtr.ReadElementString("AssetType"));
            item.AssetID = UUID.Parse(xtr.ReadElementString("AssetID"));
            item.SaleType = Convert.ToByte(xtr.ReadElementString("SaleType"));
            item.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"));
            item.BasePermissions = Convert.ToUInt32(xtr.ReadElementString("BasePermissions"));
            item.CurrentPermissions = Convert.ToUInt32(xtr.ReadElementString("CurrentPermissions"));
            item.EveryOnePermissions = Convert.ToUInt32(xtr.ReadElementString("EveryOnePermissions"));
            item.NextPermissions = Convert.ToUInt32(xtr.ReadElementString("NextPermissions"));
            item.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"));
            item.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"));
            item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned"));

            xtr.ReadEndElement();

            xtr.Close();
            sr.Close();

            return item;
        }
Esempio n. 3
0
        public static void Main()
        {
            using (XmlTextWriter writer = new XmlTextWriter("../../albums.xml", Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();
                writer.WriteStartElement("albums");

                using (XmlTextReader reader = new XmlTextReader("../../catalog.xml"))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "name")
                            {
                                writer.WriteStartElement("album");
                                writer.WriteElementString("name", reader.ReadElementString());
                            }

                            if (reader.Name == "artist")
                            {
                                writer.WriteElementString("artist", reader.ReadElementString());
                                writer.WriteEndElement();
                            }
                        }
                    }
                }

                writer.WriteEndDocument();
            }
        }
Esempio n. 4
0
        private static void Main(string[] args)
        {
            // 8. Write a program, which (using XmlReader and XmlWriter) reads the file catalog.xml and creates the file album.xml,
            // in which stores in appropriate way the names of all albums and their authors

            Encoding encoding = Encoding.UTF8;

            using (XmlTextWriter writer = new XmlTextWriter(FileToWrite, encoding))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;
                writer.WriteStartDocument();
                writer.WriteStartElement("albums");

                using (XmlTextReader reader = new XmlTextReader(FileToRead))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "name")
                        {
                            writer.WriteStartElement("album");
                            writer.WriteElementString("name", reader.ReadElementString());
                        }
                        else if (reader.NodeType == XmlNodeType.Element && reader.Name == "artist")
                        {
                            writer.WriteElementString("artist", reader.ReadElementString());
                            writer.WriteEndElement();
                        }
                    }
                }

                writer.WriteEndDocument();
            }
        }
Esempio n. 5
0
        static void PopulateCache(Dictionary<Key, GenericXmlSecurityToken> cache, Stream stream)
        {
            XmlTextReader reader = new XmlTextReader(stream);
            while (reader.IsStartElement("Entry"))
            {
                reader.ReadStartElement();
                Uri target = new Uri(reader.ReadElementString("Target"));
                string issuerStr = reader.ReadElementString("Issuer");
                Uri issuer = string.IsNullOrEmpty(issuerStr) ? null : new Uri(issuerStr);

                reader.ReadStartElement("Token");
                reader.ReadStartElement("XML");
                XmlDocument doc = new XmlDocument();
                XmlElement tokenXml = doc.ReadNode(reader) as XmlElement;
                reader.ReadEndElement();
                byte[] key = Convert.FromBase64String(reader.ReadElementString("Key"));
                reader.ReadElementString("Id");
                DateTime validFrom = Convert.ToDateTime(reader.ReadElementString("ValidFrom"));
                DateTime validTo = Convert.ToDateTime(reader.ReadElementString("ValidTo"));
                WSSecurityTokenSerializer serializer = new WSSecurityTokenSerializer();
                reader.ReadStartElement("InternalTokenReference");
                SecurityKeyIdentifierClause internalReference = serializer.ReadKeyIdentifierClause(reader);
                reader.ReadEndElement();
                reader.ReadStartElement("ExternalTokenReference");
                SecurityKeyIdentifierClause externalReference = serializer.ReadKeyIdentifierClause(reader);
                reader.ReadEndElement();
                reader.ReadEndElement(); // token
                reader.ReadEndElement(); // entry

                List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>();
                GenericXmlSecurityToken token = new GenericXmlSecurityToken(tokenXml, new BinarySecretSecurityToken(key), validFrom, validTo, internalReference, externalReference,
                    new ReadOnlyCollection<IAuthorizationPolicy>(policies));
                cache.Add(new Key(target, issuer), token);
            }
        }
        public void LoadPIDSetting_FromXmlTextReader(ref XmlTextReader xml_reader)
        {
            this.cycle_time_in_seconds = Double.Parse(xml_reader.ReadElementString("cycle_time_in_seconds"));

            xml_reader.ReadStartElement("outer_zone");
            this.proportional_band_EachZone[0] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[0] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();

            xml_reader.ReadStartElement("sample_zone");
            this.proportional_band_EachZone[1] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[1] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();

            xml_reader.ReadStartElement("inner_zone");
            this.proportional_band_EachZone[2] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[2] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();
        }
Esempio n. 7
0
        public static void Main()
        {
            var writer = new XmlTextWriter("../../album.xml", Encoding.UTF8);

            using (writer)
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';

                writer.WriteStartDocument();
                writer.WriteStartElement("albums");

                var reader = new XmlTextReader("../../catalog.xml");

                using (reader)
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "name")
                            {
                                writer.WriteStartElement("album");
                                var albumName = reader.ReadElementString();
                                writer.WriteElementString("name", albumName);
                            }
                            else if (reader.Name == "artist")
                            {
                                var artistName = reader.ReadElementString();
                                writer.WriteElementString("artist", artistName);
                                writer.WriteEndElement();
                            }
                        }
                    }
                }

                writer.WriteEndDocument();
            }

            Console.WriteLine("albums.xml created");
            Console.WriteLine(new string('-', 30));
            var document = XDocument.Load("../../album.xml");
            var albumElements = document.Element("albums").Elements("album");

            foreach (var album in albumElements)
            {
                var albumName = album.Element("name").Value;
                Console.WriteLine("Album: {0}", albumName);

                var albumArtist = album.Element("artist").Value;
                Console.WriteLine("Artist: {0}", albumArtist);
                Console.WriteLine();
            }
        }
Esempio n. 8
0
        private void FromXml(String xmlStream)
        {
            try
            {
                StringReader stringReader = new StringReader(xmlStream);
                XmlTextReader reader = new XmlTextReader(stringReader);
                while (reader.EOF == false)
                {
                    reader.ReadStartElement("ValidationContext");
                    String generateSummaryResults = reader.ReadElementString("GenerateSummaryResults");
                    if (generateSummaryResults == "true")
                    {
                        _generateSummaryResults = true;
                    }
                    String generateDetailedResults = reader.ReadElementString("GenerateDetailedResults");
                    if (generateDetailedResults == "true")
                    {
                        _generateDetailedResults = true;
                    }
                    // ...
                    // EVS Specific Context properties
                    // ...
                    reader.ReadElementString("EvsSpecificContext");

                    reader.ReadEndElement();
                }
                reader.Close();
            }
            catch (Exception e)
            {
                String message = String.Format("Failed to FromXml() DVTK DICOM EVS Validation Context XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message);
                throw new Exception(message, e);
            }
        }
		public static DatabaseConfiguration Read (string file)
		{
			DatabaseConfiguration config = new DatabaseConfiguration ();
			
			StreamReader s = new StreamReader (file);
			using (s) {
				XmlTextReader tr = new XmlTextReader (s);
				tr.MoveToContent ();
				tr.ReadStartElement ("Configuration");
				tr.MoveToContent ();
				tr.ReadStartElement ("DisabledAddins");
				tr.MoveToContent ();
				if (!tr.IsEmptyElement) {
					while (tr.NodeType != XmlNodeType.EndElement) {
						if (tr.NodeType == XmlNodeType.Element) {
							if (tr.LocalName == "Addin")
								config.DisabledAddins.Add (tr.ReadElementString ());
						}
						else
							tr.Skip ();
						tr.MoveToContent ();
					}
				}
			}
			return config;
		}
Esempio n. 10
0
        public void getData(ref SortedDictionary<string,string> data, ref List<string> localizations)
        {
            XmlTextReader reader = new XmlTextReader (fileName);

            string currentLocal=GameConfig.Localization;
            string key;
            string value;

                reader.Read();

                while (reader.Read()) {

                    if (reader.Name.Equals(LOCALIZATION_NAME)) {
                        currentLocal = reader.GetAttribute(LOCALIZATION_ATTRIBUTE);

                        if (!localizations.Contains(currentLocal))
                            localizations.Add(currentLocal);

                    }

                    if(reader.Name.Equals(ITEM_NAME)){

                        key = reader.GetAttribute(ITEM_ATTRIBUTE);
                        value = reader.ReadElementString();

                        if (key!=null)
                            data.Add(currentLocal+key, value);

                    }
                }

            reader.Close();
            reader  = null;
        }
        public void ReadXml(XmlTextReader xmlReader)
        {
            try
            {
                bool isEndCycle = false;

                while (xmlReader.Read() && !isEndCycle)
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        if (xmlReader.Name.Equals("html_text"))
                        {
                            response.DocumentHtml = QuestionXmlReader.XmlToHtml(xmlReader.ReadElementString());
                        }
                    }
                    else if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        if (xmlReader.Name.ToLower().Equals("answer"))
                        {
                            isEndCycle = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Instance.LogException(ex);
            }
        }
Esempio n. 12
0
        public static CharacterInformation Read(XmlTextReader reader)
        {
            reader.ReadStartElement ("Class");
            string name = reader.ReadElementString ("Name");
            reader.ReadEndElement();

            return new CharacterInformation
            {
                Class = name
            };
        }
Esempio n. 13
0
 public static string ReadElementString( XmlTextReader reader, string name, string defaultValue )
 {
     try
     {
         return reader.ReadElementString( name );
     }
     catch (System.Exception)
     {
         return defaultValue;
     }
 }
Esempio n. 14
0
        public static ArcanaPlayer ReadCharacter(XmlTextReader reader)
        {
            reader.ReadStartElement ("Character");

            int id = Convert.ToInt32 (reader.ReadElementString ("CharacterID"));
            string name = reader.ReadElementString ("Name");
            string pclass = reader.ReadElementString ("Class");
            int level = Convert.ToInt32 (reader.ReadElementString ("Level"));

            reader.ReadEndElement ();

            ArcanaPlayer p = classConstructors[pclass] ();
            {
                p.CharacterID = id;
                p.Name = name;
                p.Class = pclass;
                p.Level = level;
            }
            return p;
        }
Esempio n. 15
0
        public static DatabaseConfiguration Read(string file)
        {
            DatabaseConfiguration config = new DatabaseConfiguration ();

            StreamReader s = new StreamReader (file);
            using (s) {
                XmlTextReader tr = new XmlTextReader (s);
                tr.MoveToContent ();
                if (tr.IsEmptyElement)
                    return config;

                tr.ReadStartElement ("Configuration");
                tr.MoveToContent ();

                while (tr.NodeType != XmlNodeType.EndElement) {

                    if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
                        tr.Skip ();
                    }
                    else if (tr.LocalName == "DisabledAddins") {
                        // For back compatibility
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
                                config.addinStatus [tr.ReadElementString ()] = null;
                            else
                                tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    else if (tr.LocalName == "AddinStatus") {
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
                                string aid = tr.GetAttribute ("id");
                                string senabled = tr.GetAttribute ("enabled");
                                if (senabled.Length == 0 || senabled == "True")
                                    config.addinStatus [aid] = config;
                                else
                                    config.addinStatus [aid] = null;
                            }
                            tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    tr.MoveToContent ();
                }
            }
            return config;
        }
        public static QuestionWithVariants QuestionWithVariants(XmlTextReader xtr)
        {
            var question=new QuestionWithVariants
            {
                TestType = xtr.GetAttribute("type"),
                Number = Convert.ToInt32(xtr.GetAttribute("number"))
            };

            xtr.Read(); // advance to <text> tag
            question.Text = xtr.ReadElementString("text"); // consumes the </text> tag
            question.Answer = xtr.ReadElementString("answer"); // consumes the </answer> tag
            xtr.Read(); // advance to <variantsanswer> tag

            question.VariantAnswers=new List<VariantAnswer>();
            while (xtr.NodeType != XmlNodeType.EndElement)
            {
                question.VariantAnswers.Add(new VariantAnswer{Text = xtr.ReadElementString("variant")});
            }
            xtr.Read();
            return question;
        }
Esempio n. 17
0
        static Book[] XmlTextReaderHelp(string path)
        {
            XmlTextReader reader = new XmlTextReader(path);
            List<Book> bookList = new List<Book>();
            Book book = new Book();
            while(reader.Read())
            {
                if(reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "book")
                    {
                        book.Type = reader.GetAttribute(0);
                        book.ISBN = reader.GetAttribute(1);
                    }
                    if(reader.Name == "name")
                    {
                        book.Name = reader.ReadElementString().Trim();
                    }
                    if (reader.Name == "author")
                    {
                        book.Author = reader.ReadElementString().Trim();
                    }
                    if (reader.Name == "price")
                    {
                        float price;
                        if( float.TryParse(reader.ReadElementString().Trim(),out price))
                        {
                           book.Price = price ;
                        }
                    }
                }
                if(reader.NodeType == XmlNodeType.EndElement)
                {
                    bookList.Add(book) ;
                    book = new Book() ;
                }

            }
            return bookList.ToArray();
        }
Esempio n. 18
0
 private static void Main()
 {
     using (XmlReader reader = new XmlTextReader("../../catalog.xml"))
     {
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element && reader.Name == "title")
             {
                 Console.WriteLine("* " +reader.ReadElementString() + " *");
             }
         }
     }
 }
Esempio n. 19
0
        private static void ExtractAllAlbumsAndTheirAuthorsInXML(string fileLocation)
        {
            var albumsLocation = "../../xml/album.xml";

            using (var reader = new XmlTextReader(fileLocation))
            {
                using (var writer = new XmlTextWriter(albumsLocation, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    writer.IndentChar = '\t';
                    writer.Indentation = 1;

                    writer.WriteStartDocument();
                    writer.WriteStartElement("albums");

                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "name")
                        {
                            writer.WriteStartElement("album");
                            writer.WriteStartElement("name");
                            writer.WriteString(reader.ReadElementString());
                            writer.WriteEndElement();
                        }
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "artist")
                        {
                            writer.WriteStartElement("artist");
                            writer.WriteString(reader.ReadElementString());
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
            }
            Console.WriteLine("Albums and their authors .xml generated in xml/album.xml \n");
        }
Esempio n. 20
0
 static void Main(string[] args)
 {
     using (XmlReader reader = new XmlTextReader("../../catalog.xml"))
     {
         while (reader.Read())
         {
             if (reader.Name == "title")
             {
                 Console.WriteLine(reader.ReadElementString());
             }
         }
     }
 }
Esempio n. 21
0
        public ArrayList ReadStringTable(Stream input)
        {
            ArrayList stringTable = new ArrayList();

            using (XmlTextReader reader = new XmlTextReader(input))
            {
                for (reader.MoveToContent(); reader.Read(); )
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "t")
                        stringTable.Add(reader.ReadElementString());
            }

            return stringTable;
        }
Esempio n. 22
0
        public  string readConnection()
        {

            string connectionString = "";
            XmlTextReader m_xmlr = default(XmlTextReader);
            //Create the XML Reader

            m_xmlr = new XmlTextReader("product.xml");
            //Disable whitespace so that you don't have to read over whitespaces

            m_xmlr.WhitespaceHandling = WhitespaceHandling.None;
            //read the xml declaration and advance to family tag

            m_xmlr.Read();
            //read the family tag

            m_xmlr.Read();
            //Load the Loop

            while (!m_xmlr.EOF)
            {
                //Go to the name tag

                m_xmlr.Read();
                //if not start element exit while loop

                if (!m_xmlr.IsStartElement())
                {
                    break; // TODO: might not be correct. Was : Exit While
                }
                //Get the Gender Attribute Value

                dynamic Attribute = m_xmlr.GetAttribute("Application_Configaration");
                //Read elements firstname and lastname

                m_xmlr.Read();
                //Get the firstName Element Value

                connectionString = m_xmlr.ReadElementString("Connection_String");



            }
            //close the reader

            m_xmlr.Close();
            return connectionString;



        }
Esempio n. 23
0
 private static string config(string url, string bien)
 {
     string _config = "";
     XmlTextReader xmlReader = new XmlTextReader(url);
     while (xmlReader.Read())
     {
         if (xmlReader.Name == bien)
         {
             _config = xmlReader.ReadElementString();
         }
     }
     xmlReader.Close();
     return _config;
 }
Esempio n. 24
0
 public LocationResponse(WebResponse response)
     : base(response)
 {
     try
     {
         XmlTextReader r = new XmlTextReader(response.GetResponseStream());
         while (r.Read() && !r.IsStartElement())
             ;
         this.location = r.ReadElementString("LocationConstraint");
         if (this.location == null)
             this.location = "";
     }
     catch (XmlException)
     {
     }
 }
Esempio n. 25
0
        //  XmlReaderSample2/form.cs
        protected void button1_Click(object sender, System.EventArgs e)
        {
            //use a filestream to get the data
            FileStream fs = new FileStream("..\\books.xml",FileMode.Open);
            XmlTextReader tr = new XmlTextReader(fs);

            while(!tr.EOF)
            {
                //if we hit an element type, try and load it in the listbox
                if(tr.MoveToContent()==XmlNodeType.Element && tr.Name=="title")
                {
                    listBox1.Items.Add(tr.ReadElementString());
                }
                else
                    //otherwise move on
                    tr.Read();
            }
        }
      public static void Main()
        {
            var reader = new XmlTextReader("../../catalog.xml");
            Console.WriteLine("Song titles: ");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine(new string('-', 30));

            using (reader)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "title")
                    {
                        var title = reader.ReadElementString();
                        Console.WriteLine(title);
                        Console.WriteLine();
                    }
                }
            }
        }
        public static void WithXmlReader(string fileLocation)
        {
            Console.WriteLine("All song titles in the document: \n");
            using (XmlReader reader = new XmlTextReader(fileLocation))
            {
                var songList = new List<string>();

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "title")
                    {
                        var songTitle = reader.ReadElementString();

                        if (!songList.Contains(songTitle))
                        {
                            songList.Add(songTitle);
                            Console.WriteLine(songTitle);
                        }
                    }
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Parses table from byte[] xml data.
        /// </summary>
        /// <param name="data">Table data.</param>
        public void Parse(byte[] data)
        {
            m_pValues.Clear();

            MemoryStream ms = new MemoryStream(data);
            XmlTextReader wr = new XmlTextReader(ms);
            
            // Read start element
            wr.Read();

            m_TableName = wr.LocalName;
                      
            // Read Name/Values
            while(wr.Read()){            
                if(wr.NodeType == XmlNodeType.Element){
                    this.Add(wr.LocalName,wr.ReadElementString());
                }
            }
        }
		static string ReadGenericProjectType (string file)
		{
			using (XmlTextReader tr = new XmlTextReader (file)) {
				tr.MoveToContent ();
				if (tr.LocalName != "Project")
					return null;
				if (tr.IsEmptyElement)
					return null;
				tr.ReadStartElement ();
				tr.MoveToContent ();
				if (tr.LocalName != "PropertyGroup")
					return null;
				if (tr.IsEmptyElement)
					return null;
				tr.ReadStartElement ();
				tr.MoveToContent ();
				while (tr.NodeType != XmlNodeType.EndElement) {
					if (tr.NodeType == XmlNodeType.Element && !tr.IsEmptyElement && tr.LocalName == "ItemType")
						return tr.ReadElementString ();
					tr.Skip ();
				}
				return null;
			}
		}
Esempio n. 30
0
        public void TestSerializeXml2()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            string rpName = "My Little Pony";
            UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000064");
            UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000015");
            PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
//            Vector3 groupPosition = new Vector3(10, 20, 30);
//            Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
//            Vector3 offsetPosition = new Vector3(5, 10, 15);

            SceneObjectPart rp = new SceneObjectPart();
            rp.UUID = rpUuid;
            rp.Name = rpName;
            rp.CreatorID = rpCreatorId;
            rp.Shape = shape;

            SceneObjectGroup so = new SceneObjectGroup(rp);

            // Need to add the object to the scene so that the request to get script state succeeds
            m_scene.AddSceneObject(so);

            string xml2 = m_serialiserModule.SerializeGroupToXml2(so);

            XmlTextReader xtr = new XmlTextReader(new StringReader(xml2));
            xtr.ReadStartElement("SceneObjectGroup");
            xtr.ReadStartElement("SceneObjectPart");
           
            UUID uuid = UUID.Zero;
            string name = null;
            UUID creatorId = UUID.Zero;

            while (xtr.Read() && xtr.Name != "SceneObjectPart")
            {
                if (xtr.NodeType != XmlNodeType.Element)
                    continue;
                
                switch (xtr.Name)
                {
                    case "UUID":
                        xtr.ReadStartElement("UUID");
                        uuid = UUID.Parse(xtr.ReadElementString("Guid"));
                        xtr.ReadEndElement();
                        break;
                    case "Name":
                        name = xtr.ReadElementContentAsString();
                        break;
                    case "CreatorID":
                        xtr.ReadStartElement("CreatorID");
                        creatorId = UUID.Parse(xtr.ReadElementString("Guid"));
                        xtr.ReadEndElement();
                        break;
                }
            }

            xtr.ReadEndElement();
            xtr.ReadStartElement("OtherParts");
            xtr.ReadEndElement();
            xtr.Close();

            // TODO: More checks
            Assert.That(uuid, Is.EqualTo(rpUuid));
            Assert.That(name, Is.EqualTo(rpName));
            Assert.That(creatorId, Is.EqualTo(rpCreatorId));
        }