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


C# XmlReader.MoveToContent方法代码示例

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


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

示例1: Deserialize

        public object Deserialize(XmlReader xmlReader)
        {
            XmlRootAttribute xmlRootAttribute = (XmlRootAttribute) _type.GetCustomAttributes(typeof(XmlRootAttribute), false).SingleOrDefault();
            string rootElement = null == xmlRootAttribute
                                     ? _type.Name
                                     : xmlRootAttribute.ElementName;

            xmlReader.MoveToContent();

            if (xmlReader.LocalName != rootElement)
            {
                throw new XmlException("Unexpected element");
            }

            object res = DeserializeCheckedElement(xmlReader, _type);

            // skip end tag
            while (xmlReader.Read())
            {
                xmlReader.MoveToContent();
            }

            if (! xmlReader.EOF)
            {
                throw new XmlException("Invalid xml content");
            }

            return res;
        }
开发者ID:kpaskal,项目名称:cassandra-sharp,代码行数:29,代码来源:MiniXmlSerializer.cs

示例2: 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:tablesmit,项目名称:task-scheduler-managed-wrapper,代码行数:29,代码来源:XmlSerializationHelper.cs

示例3: ReadXml

		internal static ResolveCriteria ReadXml (XmlReader reader, DiscoveryVersion version)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var ret = new ResolveCriteria ();

			reader.MoveToContent ();
			if (!reader.IsStartElement ("ResolveType", version.Namespace) || reader.IsEmptyElement)
				throw new XmlException ("Non-empty ResolveType element is expected");
			reader.ReadStartElement ("ResolveType", version.Namespace);

			// standard members
			reader.MoveToContent ();
			ret.Address = EndpointAddress.ReadFrom (version.MessageVersion.Addressing, reader);

			// non-standard members
			for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
				if (reader.NamespaceURI == SerializationNS) {
					switch (reader.LocalName) {
					case "Duration":
						ret.Duration = (TimeSpan) reader.ReadElementContentAs (typeof (TimeSpan), null);
						break;
					}
				}
				else
					ret.Extensions.Add (XElement.Load (reader));
			}

			reader.ReadEndElement ();

			return ret;
		}
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:ResolveCriteria.cs

示例4: ReadXml

		public override void ReadXml(XmlReader reader)
		{
			reader.MoveToContent();
			if (reader.AttributeCount == 0)
				throw new MissingXmlAttributeException(@"Missing XML attribute ""value"".");
			Name = reader["name"];

			if (reader.IsEmptyElement)
			{
				reader.ReadEndElement();
				return;
			}


			if (reader.ReadToDescendant(ChildXmlTag))
			{
				while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == ChildXmlTag)
				{
					reader.ReadStartElement();
					reader.MoveToContent();

					IilParameter p = IilParameter.fromString(reader.LocalName);
					p.ReadXml(reader);
					Parameters.Add(p);
					reader.ReadEndElement();
				}
			}
			
            
			reader.ReadEndElement();
			//reader.Read();
		}
开发者ID:jannickj,项目名称:multipacman,代码行数:32,代码来源:IilDataContainer.cs

示例5: ReadXml

		public void ReadXml(XmlReader reader)
		{
			reader.MoveToContent();
			var empty = reader.IsEmptyElement;
			reader.ReadStartElement();
			if (!empty)
			{
				while (reader.MoveToContent() == XmlNodeType.Element)
				{
					if (reader.Name == @"ProductName" && !reader.IsEmptyElement)
					{
						ProductName = reader.ReadElementString();
					}
					else if (reader.Name == @"GlyphColor" && !reader.IsEmptyElement)
					{
						GlyphColor = ParseColor(reader.ReadElementString());
					}
					else
					{
						// consume the bad element and skip to next sibling or the parent end element tag
						reader.ReadOuterXml();
					}
				}
				reader.MoveToContent();
				reader.ReadEndElement();
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:27,代码来源:OemConfiguration.cs

示例6: GetFeed

		public static IFeed GetFeed(Uri url, XmlReader reader) {
			reader.MoveToContent();
			string language = string.Empty;
			FeedType feedType;
			string namespaceUri = reader.NamespaceURI;
			if(reader.LocalName.Equals("RDF") &&
				reader.NamespaceURI.Equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) {
				feedType = FeedType.Rdf;
				reader.Read();
				reader.MoveToContent();
			} else if(reader.LocalName.Equals("rss")) {
				feedType = FeedType.Rss;

				do {
					reader.Read();
					reader.MoveToContent();
				} while(!reader.LocalName.Equals("channel") && !reader.LocalName.Equals("rss"));
			} else if(reader.NamespaceURI.Equals("http://purl.org/atom/ns#") && reader.LocalName.Equals("feed")) {
				if(reader.MoveToAttribute("version") && reader.Value.Equals("0.3")) {
					feedType = FeedType.Atom;
					language = reader.XmlLang;
					reader.MoveToElement();
				} else {
					throw new ApplicationException(string.Format("Unsupported Atom Version {0}", reader.Value));
				}
			} else if(reader.NamespaceURI.Equals("http://www.w3.org/2005/Atom") && reader.LocalName.Equals("feed")) {
				feedType = FeedType.Atom;
				language = reader.XmlLang;
			} else {
				throw new ApplicationException("Unknown Xml Dialect");
			}
			return PopulateFeed(url, reader, namespaceUri, feedType, language);
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:33,代码来源:FeedReader.cs

示例7: ProcessItem

        private void ProcessItem(XmlReader reader)
        {
            reader.MoveToContent();

            Material tmpMaterial = new Material();

            tmpMaterial.name = reader.GetAttribute("displayname");
            tmpMaterial.type = reader.GetAttribute("type");

            if (reader.ReadToFollowing("ambient"))
            {
                reader.MoveToContent();
                tmpMaterial.ambient.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.ambient.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.ambient.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.ambient.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("specular"))
            {
                reader.MoveToContent();
                tmpMaterial.specular.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.specular.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.specular.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.specular.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("diffuse"))
            {
                reader.MoveToContent();
                tmpMaterial.diffuse.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.diffuse.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.diffuse.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.diffuse.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("emissive"))
            {
                reader.MoveToContent();
                tmpMaterial.emission.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.emission.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.emission.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.emission.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("shininess"))
            {
                reader.MoveToContent();
                tmpMaterial.shininess = (float)Convert.ToDouble(reader.GetAttribute("value").Replace(".", ","));
            }
            if (reader.ReadToFollowing("texture"))
            {
                reader.MoveToContent();
                tmpMaterial.LoadTexture(reader.GetAttribute("file"));
            }
            this.lstMaterial.Add(tmpMaterial);
        }
开发者ID:dankar,项目名称:zombies,代码行数:53,代码来源:MaterialReader.cs

示例8: ReadPinboardXml

        private static PinboardData ReadPinboardXml(XmlReader reader)
        {
            PinboardData data = new PinboardData();

            reader.ReadStartElement("Pinboard");
            reader.MoveToContent();
            data.ScreenRectInfo = ReadRectangleXml(reader);

            data.RectInfos = ReadRectanglesXml(reader);

            reader.ReadEndElement();
            reader.MoveToContent();

            return data;
        }
开发者ID:dellis1972,项目名称:XnaBuildContent,代码行数:15,代码来源:PinboardDataReaderV1.cs

示例9: CanRead

		public static bool CanRead (XmlReader xmlReader)
		{
			xmlReader.MoveToContent ();
			return xmlReader.NodeType == XmlNodeType.Element &&
					xmlReader.LocalName == "discovery" && 
					xmlReader.NamespaceURI == Namespace;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:DiscoveryDocument.cs

示例10: ReadXml

 public void ReadXml(XmlReader reader)
 {
     int count;
     reader.MoveToContent();
     int.TryParse(reader["ChildrenCount"], out count);
     reader.ReadStartElement("Professionbuddy");
     PrioritySelector ps = (PrioritySelector)DecoratedChild;
     for (int i = 0; i < count; i++)
     {
         Type type = Type.GetType("HighVoltz.Composites." + reader.Name);
         if (type != null)
         {
             IPBComposite comp = (IPBComposite)Activator.CreateInstance(type);
             if (comp != null)
             {
                 comp.ReadXml(reader);
                 ps.AddChild((Composite)comp);
             }
         }
         else
         {
             Professionbuddy.Err("PB:Failed to load type {0}", type);
         }
     }
     if (reader.NodeType == XmlNodeType.EndElement)
         reader.ReadEndElement();
 }
开发者ID:naacra,项目名称:wowhbbotcracked,代码行数:27,代码来源:PBIdentityComposite.cs

示例11: ReadXml

        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();

            Repeat = Convert.ToInt32(reader["Repeat"], CultureInfo.InvariantCulture);

            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Frames":
                            ReadFramesXml(reader);
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
开发者ID:jaquadro,项目名称:Amphibian,代码行数:32,代码来源:XmlAnimationElement.cs

示例12: ReadXml

        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();

            DefaultAnimation = reader["DefaultAnimation"];

            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Activity":
                            XmlActivityElement activity = new XmlActivityElement();
                            activity.ReadXml(reader);
                            Activities.Add(activity);
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
开发者ID:jaquadro,项目名称:Amphibian,代码行数:34,代码来源:XmlActivityMapElement.cs

示例13: ReadXml

        public static KeyValuePair<string, Property> ReadXml(XmlReader reader)
        {
            var key = reader.GetAttribute("Key");
            var type = reader.GetAttribute("Type");

            reader.MoveToElement();
            reader.ReadStartElement("PropertyEntry");
            Property value = null;
            try
            {
                var t = Type.GetType(type);
                value = (Property)GetSerializer(t).Deserialize(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Deserialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Type Qualified Name: " + type);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            reader.ReadEndElement();
            reader.MoveToContent();
            if (value == null)
                throw new Exception();
            return new KeyValuePair<string, Property>(key, value);
        }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:27,代码来源:PropertyEntryMultiSerializer.cs

示例14: ReadXml

 /// <summary>Generates an object from its XML representation.</summary>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is
 /// deserialized.</param>
 public override void ReadXml(XmlReader reader)
 {
     reader.MoveToContent();
     reader.ReadStartElement();
     Descriptor = Xml.Read<Descriptor>(reader);
     Root = Xml.Read<Measure>(reader);
 }
开发者ID:m-abubakar,项目名称:numl,代码行数:10,代码来源:NaiveBayesModel.cs

示例15: CanRead

		public override bool CanRead (XmlReader reader)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");
			reader.MoveToContent ();
			return reader.LocalName == "service" && reader.NamespaceURI == Version;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:AtomPub10ServiceDocumentFormatter.cs


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