示例#1
0
        /// <summary>
        /// Convert a string containing xml to an <see cref="System.Data.SqlTypes.SqlXml">SqlXml</see> instance.
        /// <para>The xmlReaderSettings are used when creating the internal XmlReader that actually does the conversion.</para>
        /// </summary>
        /// <param name="xml">A <see cref="System.String">String</see> containing xml.</param>
        /// <param name="xmlReaderSettings"></param>
        /// <returns></returns>
        public static SqlXml GetSqlXml(this String xml, XmlReaderSettings xmlReaderSettings)
        {
            xml.Name("xml").NotNullEmptyOrOnlyWhitespace();
            xmlReaderSettings.Name("xmlReaderSettings").NotNull();

            using (var stringReader = new StringReader(xml))
                using (var xmlReader = XmlReader.Create(stringReader, xmlReaderSettings))
                    return(new SqlXml(xmlReader));
        }