예제 #1
0
        /// <summary>
        /// Extends ReadElementContentAs so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// xmlreader.ReadElementContentAs<int>(namespaceResolver, localName, namespaceURI);
        /// </example>
        /// </summary>
        public static T ReadElementContentAs <T>(this XmlValidatingReader xmlreader, IXmlNamespaceResolver namespaceResolver, String localName, String namespaceURI)
        {
            if (xmlreader == null)
            {
                throw new ArgumentNullException("xmlreader");
            }

            return((T)xmlreader.ReadElementContentAs(typeof(T), namespaceResolver, localName, namespaceURI));
        }
#pragma warning disable CS0618 // 'XmlValidatingReader' is obsolete: 'Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202'
        /// <summary>
        /// Extends ReadElementContentAs so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// xmlreader.ReadElementContentAs&lt;int&gt;(namespaceResolver, localName, namespaceURI);
        /// </example>
        /// </summary>
        public static T ReadElementContentAs <T>(this XmlValidatingReader xmlreader, IXmlNamespaceResolver namespaceResolver, String localName, String namespaceURI)
#pragma warning restore CS0618 // 'XmlValidatingReader' is obsolete: 'Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202'
        {
            if (xmlreader == null)
            {
                throw new ArgumentNullException("xmlreader");
            }

            return((T)xmlreader.ReadElementContentAs(typeof(T), namespaceResolver, localName, namespaceURI));
        }