public object TokenizeFromXml(XmlReader reader) { reader.ReadStartElement(); Geography geography = GmlFormatter.Create().Read <Geography>(reader); reader.SkipInsignificantNodes(); return(geography); }
internal static void ReadPayloadStart(this XmlReader reader) { reader.SkipInsignificantNodes(); if (reader.NodeType != XmlNodeType.Element) { throw new ODataException(Strings.XmlReaderExtension_InvalidRootNode(reader.NodeType)); } }
internal static void ReadPayloadEnd(this XmlReader reader) { reader.SkipInsignificantNodes(); if ((reader.NodeType != XmlNodeType.None) && !reader.EOF) { throw new ODataException(Strings.XmlReaderExtension_InvalidRootNode(reader.NodeType)); } }
/// <summary> /// Create a geography instance from the value in an Xml reader. /// </summary> /// <param name="reader">The Xml reader to use to read the value.</param> /// <remarks>In order to be consistent with how we are reading other types of property values elsewhere in the product, the reader /// is expected to be placed at the beginning of the element when entering this method. After this method call, the reader will be placed /// at the EndElement, such that the next Element will be read in the next Read call. The deserializer that uses this value expects /// the reader to be in these states when entering and leaving the method. /// </remarks> /// <returns>Geography instance that was read.</returns> public object TokenizeFromXml(XmlReader reader) { Debug.Assert(reader.NodeType == XmlNodeType.Element, "reader at element"); reader.ReadStartElement(); // <d:Property> Geography geography = GmlFormatter.Create().Read<Geography>(reader); reader.SkipInsignificantNodes(); Debug.Assert(reader.NodeType == XmlNodeType.EndElement, "reader at end of current element"); return geography; }
/// <summary> /// Create a geography instance from the value in an Xml reader. /// </summary> /// <param name="reader">The Xml reader to use to read the value.</param> /// <remarks>In order to be consistent with how we are reading other types of property values elsewhere in the product, the reader /// is expected to be placed at the beginning of the element when entering this method. After this method call, the reader will be placed /// at the EndElement, such that the next Element will be read in the next Read call. The deserializer that uses this value expects /// the reader to be in these states when entering and leaving the method. /// </remarks> /// <returns>Geography instance that was read.</returns> public object TokenizeFromXml(XmlReader reader) { Debug.Assert(reader.NodeType == XmlNodeType.Element, "reader at element"); reader.ReadStartElement(); // <d:Property> Geography geography = GmlFormatter.Create().Read <Geography>(reader); reader.SkipInsignificantNodes(); Debug.Assert(reader.NodeType == XmlNodeType.EndElement, "reader at end of current element"); return(geography); }
/// <summary> /// Reads from the input until the first element is found. /// </summary> /// <param name="reader">The XML reader to read from.</param> /// <remarks> /// Pre-Condition: XmlNodeType.None - the reader hasn't been used yet. /// Post-Condition: XmlNodeType.Element - the reader is positioned on the root/first element. /// Note that the method will fail if the top-level contains any significant node other than the root element /// or if no root element is found. /// </remarks> internal static void ReadPayloadStart(this XmlReader reader) { Debug.Assert(reader != null, "reader != null"); Debug.Assert(reader.NodeType == XmlNodeType.None, "Pre-Condition: XML reader must not have been used yet."); reader.SkipInsignificantNodes(); if (reader.NodeType != XmlNodeType.Element) { throw new ODataException(Strings.XmlReaderExtension_InvalidRootNode(reader.NodeType)); } Debug.Assert(reader.NodeType == XmlNodeType.Element, "Post-Condition: XML reader must be on Element node."); }
/// <summary> /// Reads till the end of the input payload. /// </summary> /// <param name="reader">The XML reader to read from.</param> /// <remarks> /// Pre-Condition: any - the reader will verify that only insignificant node is present. /// Post-Condition: XmlNodeType.None - the reader is at the end of the input. /// </remarks> internal static void ReadPayloadEnd(this XmlReader reader) { Debug.Assert(reader != null, "reader != null"); reader.SkipInsignificantNodes(); if (reader.NodeType != XmlNodeType.None && !reader.EOF) { throw new ODataException(Strings.XmlReaderExtension_InvalidRootNode(reader.NodeType)); } Debug.Assert( reader.NodeType == XmlNodeType.None && reader.EOF, "Post-Condition: XML reader must be positioned at the end of the input."); }