System.Xml.XmlConvert.VerifyCharData C# (CSharp) Method

VerifyCharData() static private method

static private VerifyCharData ( string data, ExceptionType invCharExceptionType, ExceptionType invSurrogateExceptionType ) : void
data string
invCharExceptionType ExceptionType
invSurrogateExceptionType ExceptionType
return void
        internal static unsafe void VerifyCharData(string data, ExceptionType invCharExceptionType, ExceptionType invSurrogateExceptionType)
        {
            if (data == null || data.Length == 0)
            {
                return;
            }

            int i = 0;
            int len = data.Length;
            for (;;)
            {
                while (i < len && s_xmlCharType.IsCharData(data[i]))
                {
                    i++;
                }
                if (i == len)
                {
                    return;
                }

                char ch = data[i];
                if (XmlCharType.IsHighSurrogate(ch))
                {
                    if (i + 1 == len)
                    {
                        throw CreateException(SR.Xml_InvalidSurrogateMissingLowChar, invSurrogateExceptionType, 0, i + 1);
                    }
                    ch = data[i + 1];
                    if (XmlCharType.IsLowSurrogate(ch))
                    {
                        i += 2;
                        continue;
                    }
                    else
                    {
                        throw CreateInvalidSurrogatePairException(data[i + 1], data[i], invSurrogateExceptionType, 0, i + 1);
                    }
                }
                throw CreateInvalidCharException(data, i, invCharExceptionType);
            }
        }

Same methods

XmlConvert::VerifyCharData ( char data, int offset, int len, ExceptionType exceptionType ) : void
XmlConvert::VerifyCharData ( string data, ExceptionType exceptionType ) : void

Usage Example

示例#1
0
        public override void WriteString(string?text)
        {
            VerifyState(Method.WriteString);
            XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException);
            XmlNode node = _document.CreateTextNode(text);

            AddChild(node, _write);
        }
All Usage Examples Of System.Xml.XmlConvert::VerifyCharData