System.Xml.ValidateNames.ParseNmtokenNoNamespaces C# (CSharp) Méthode

ParseNmtokenNoNamespaces() private méthode

private ParseNmtokenNoNamespaces ( string s, int offset ) : int
s string
offset int
Résultat int
        internal static unsafe int ParseNmtokenNoNamespaces(string s, int offset)
        {
            Debug.Assert(s != null && offset <= s.Length);

            // Keep parsing until the end of string or an invalid Name character is reached
            int i = offset;
            while (i < s.Length)
            {
                if (s_xmlCharType.IsNameSingleChar(s[i]) || s[i] == ':')
                {
                    i++;
                }
#if XML10_FIFTH_EDITION
                else if (xmlCharType.IsNCNameSurrogateChar(s, i))
                {
                    i += 2;
                }
#endif
                else
                {
                    break;
                }
            }

            return i - offset;
        }

Usage Example

Exemple #1
0
        internal static string VerifyNMTOKEN(string name, ExceptionType exceptionType)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw CreateException(SR.Xml_InvalidNmToken, name, exceptionType);
            }

            int endPos = ValidateNames.ParseNmtokenNoNamespaces(name, 0);

            if (endPos != name.Length)
            {
                throw CreateException(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos), exceptionType, 0, endPos + 1);
            }
            return(name);
        }