当前位置: 首页>>代码示例>>C#>>正文


C# XmlReader.ReadStartElement方法代码示例

本文整理汇总了C#中XmlReader.ReadStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadStartElement方法的具体用法?C# XmlReader.ReadStartElement怎么用?C# XmlReader.ReadStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlReader的用法示例。


在下文中一共展示了XmlReader.ReadStartElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadXml

    public void ReadXml(XmlReader reader)
    {
        reader.ReadStartElement(); //wrapping element

        this.name = reader.ReadElementContentAsString();
        this.extension = reader.ReadElementContentAsString();

        string tempFileName = Path.GetTempFileName();
        this.streamFileName = tempFileName;
        using (FileStream fs = File.Create(tempFileName))
        {
            byte[] buffer = new byte[1000];
            int bytesRead;
            reader.ReadStartElement();
            do
            {
                bytesRead = reader.ReadContentAsBase64(buffer, 0, buffer.Length);
                fs.Write(buffer, 0, bytesRead);
            } while (bytesRead > 0);

            reader.ReadEndElement();
        }

        reader.ReadEndElement(); //wrapping element
    }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:25,代码来源:ContextExtra.cs

示例2:

		 void IXmlSerializable.ReadXml(XmlReader r)
		{
			r.MoveToContent();
			r.ReadStartElement("Employee");
			
			 r.ReadStartElement("Name");
			 FirstName = r.ReadElementString("First", ns);
			 LastName = r.ReadElementString("Last", ns);
			r.ReadEndElement();
			r.MoveToContent();
			 ID = Int32.Parse(r.ReadElementString("ID", ns));
			 r.ReadEndElement();
			 
		}
开发者ID:Helen1987,项目名称:edu,代码行数:14,代码来源:EmployeesServiceCompatible.cs

示例3: LoadEnemies

	private void LoadEnemies(XmlReader reader) {
		reader.ReadStartElement("Enemies");

		GameObject enemy = null;
		bool enemyToParse = reader.ReadToFollowing ("Enemy");
		Debug.Log ("Started parsing enemies..." + enemyToParse);
		do {
			if(!enemyToParse)
				break;
			
			Debug.Log ("Found an enemy");
			switch (reader.GetAttribute ("Type")) {
			case "Bat":
				enemy = Instantiate (prefabDictionary ["Bat"]);
				break;
			case "Blob":
				enemy = Instantiate (prefabDictionary ["Blob"]);
				break;
			} 
			enemy.GetComponent<Enemy> ().Load (reader);
		} while(reader.ReadToNextSibling("Enemy"));

	}
开发者ID:TobiasMorell,项目名称:Game2Grow-Wizard,代码行数:23,代码来源:SaveLoadManager.cs

示例4: ReadObject

        public static void ReadObject(XmlReader reader, object obj, PropertyConversionHandler handler = null)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            reader.MoveToContent();

            if (obj is IXmlSerializable)
            {
                ((IXmlSerializable)obj).ReadXml(reader);
            }
            else
            {
                object oVal = null;
                string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), "ElementName", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;
                if (reader.LocalName != oName)
                    throw new XmlException("XML element name does not match object.");

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    reader.MoveToContent();
                    ReadObjectProperties(reader, obj, handler);
                    reader.ReadEndElement();
                }
                else
                    reader.Skip();
            }
        }
开发者ID:BclEx,项目名称:BclEx-Extend,代码行数:29,代码来源:XmlSerializationHelper.cs


注:本文中的XmlReader.ReadStartElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。