/// <summary> /// Peeks at the next field in the input stream and returns what information is available. /// </summary> /// <remarks> /// This may be called multiple times without actually reading the field. Only after the field /// is either read, or skipped, should PeekNext return a different value. /// </remarks> protected override bool PeekNext(out string field) { ElementStackEntry stopNode; if (_elements.Count == 0) { stopNode = new ElementStackEntry(null, _input.Depth - 1, false); } else { stopNode = _elements.Peek(); } if (!stopNode.IsEmpty) { while (!_input.IsStartElement() && _input.Depth > stopNode.Depth && _input.Read()) { continue; } if (_input.IsStartElement() && _input.Depth > stopNode.Depth) { field = _input.LocalName; return(true); } } field = null; return(false); }
/// <summary> /// Reads the root-message close specific to this formatter, MUST be called /// on the reader obtained from ReadMessageStart(string element). /// </summary> public override void ReadMessageEnd() { Assert(_elements.Count > 0); ElementStackEntry stop = _elements.Peek(); while (_input.NodeType != XmlNodeType.EndElement && _input.NodeType != XmlNodeType.Element && _input.Depth > stop.Depth && _input.Read()) { continue; } if (!stop.IsEmpty) { Assert(_input.NodeType == XmlNodeType.EndElement && _input.LocalName == stop.LocalName && _input.Depth == stop.Depth); _input.Read(); } _elements.Pop(); }