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


C# NodeInfo.Reset方法代码示例

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


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

示例1: Read

		// When reading an array (0x03), it requires extraneously
		// complex procedure for XmlReader. First, it reads element,
		// type of operation and length of the items. And this XmlReader
		// has to return Element state. On the next Read(), it proceeds
		// to the value node of the first item of the array, so it
		// reads the value stream. On the next Read(), it proceeds to
		// EndElement, so it should not read anything from stream while
		// it has to move to the node state to EndElement.
		public override bool Read ()
		{
			switch (state) {
			case ReadState.Closed:
			case ReadState.EndOfFile:
			case ReadState.Error:
				return false;
			}

			// clear.
			state = ReadState.Interactive;
			MoveToElement ();
			attr_count = 0;
			attr_value_count = 0;
			ns_slot = 0;

			if (node.NodeType == XmlNodeType.Element) {
				// push element scope
				if (node_stack.Count <= ++depth) {
					if (depth == quota.MaxDepth)
						throw new XmlException (String.Format ("Binary XML stream quota exceeded. Depth must be less than {0}", quota.MaxDepth));
					node = new NodeInfo ();
					node_stack.Add (node);
				} else {
					node = node_stack [depth]; // reuse
					node.Reset ();
				}
			}
			current = node;

			if (is_next_end_element) {
				is_next_end_element = false;
				node.Reset ();
				ProcessEndElement ();
				return true;
			}

			// process array node after preparing node stack.
			switch (array_state) {
			case XmlNodeType.Element:
				ReadArrayItem ();
				return true;
			case XmlNodeType.Text:
				ShiftToArrayItemEndElement ();
				return true;
			case XmlNodeType.EndElement:
				if (--array_item_remaining == 0) {
					array_state = XmlNodeType.None;
					break;
				} else {
					ShiftToArrayItemElement ();
					return true;
				}
			}

			// array consumer does not expect Reset whlie it's on reading. So call it later than array check.
			node.Reset ();

			int ident = next >= 0 ? next : source.ReadByte ();
			next = -1;

			// check end of source.
			if (ident < 0) {
				state = ReadState.EndOfFile;
				current.Reset ();
				return false;
			}

			is_next_end_element = ident > 0x80 && (ident & 1) == 1;
			ident -= is_next_end_element ? 1 : 0;

			switch (ident) {
			case BF.EndElement:
				ProcessEndElement ();
				break;
			case BF.Comment:
				node.Value = ReadUTF8 ();
				node.ValueType = BF.Comment;
				node.NodeType = XmlNodeType.Comment;
				break;
			case BF.ElemString:
			case BF.ElemStringPrefix:
			case BF.ElemIndex:
			case BF.ElemIndexPrefix:
				ReadElementBinary ((byte) ident);
				break;

			case BF.Array:
				ident = ReadByteOrError ();
				ReadElementBinary ((byte) ident);
				ident = ReadByteOrError ();
				if (ident != 0x01)
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: Initialize

		private void Initialize (IXmlDictionary dictionary,
			XmlDictionaryReaderQuotas quotas,
			XmlBinaryReaderSession session,
			OnXmlDictionaryReaderClose onClose)
		{
			if (quotas == null)
				throw new ArgumentNullException ("quotas");
			if (dictionary == null)
				dictionary = new XmlDictionary ();
			this.dictionary = dictionary;

			this.quota = quotas;

			if (session == null)
				session = new XmlBinaryReaderSession ();
			this.session = session;

			on_close = onClose;
			NameTable nt = new NameTable ();
			this.context = new XmlParserContext (nt,
				new XmlNamespaceManager (nt),
				null, XmlSpace.None);

			current = node = new NodeInfo ();
			current.Reset ();
			node_stack.Add (node);
		}
开发者ID:,项目名称:,代码行数:27,代码来源:


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