System.Xml.XmlConvert.VerifyCharData C# (CSharp) Méthode

VerifyCharData() static private méthode

static private VerifyCharData ( char data, int offset, int len, ExceptionType exceptionType ) : void
data char
offset int
len int
exceptionType ExceptionType
Résultat void
        internal static unsafe void VerifyCharData(char[] data, int offset, int len, ExceptionType exceptionType)
        {
            if (data == null || len == 0)
            {
                return;
            }

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

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

Same methods

XmlConvert::VerifyCharData ( string data, ExceptionType exceptionType ) : void
XmlConvert::VerifyCharData ( string data, ExceptionType invCharExceptionType, ExceptionType invSurrogateExceptionType ) : void

Usage Example

        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