| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Xml; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF |
| | | 7 | | { |
| | | 8 | | internal static class XmlReaderExtensions |
| | | 9 | | { |
| | | 10 | | internal static string ReadElementString(this XmlReader reader) |
| | | 11 | | { |
| | 0 | 12 | | if (reader.MoveToContent() != XmlNodeType.Element) |
| | | 13 | | { |
| | 0 | 14 | | var lineInfo = reader as IXmlLineInfo; |
| | 0 | 15 | | throw new XmlException(SR.Format(SR.Xml_InvalidNodeType, reader.NodeType.ToString()), null, lineInfo?.Li |
| | | 16 | | } |
| | | 17 | | |
| | 0 | 18 | | return reader.ReadElementContentAsString(); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | internal static string ReadElementString(this XmlReader reader, string localname, string ns) |
| | | 22 | | { |
| | 0 | 23 | | if (reader.MoveToContent() != XmlNodeType.Element) |
| | | 24 | | { |
| | 0 | 25 | | var lineInfo = reader as IXmlLineInfo; |
| | 0 | 26 | | throw new XmlException(SR.Format(SR.Xml_InvalidNodeType, reader.NodeType.ToString()), null, lineInfo?.Li |
| | | 27 | | } |
| | | 28 | | |
| | 0 | 29 | | return reader.ReadElementContentAsString(localname, ns); |
| | | 30 | | } |
| | | 31 | | } |
| | | 32 | | } |