ParseQName() static private method

Attempts to parse the input string as a QName (see the XML Namespace spec). Quits parsing when an invalid QName char is reached or the end of string is reached. Returns the number of valid QName chars that were parsed. Sets colonOffset to the offset of a colon character if it exists, or 0 otherwise.
static private ParseQName ( string s, int offset, int &colonOffset ) : int
s string
offset int
colonOffset int
return int
        private void ValidateQName(string name)
        {
            if (name.Length == 0)
            {
                throw new ArgumentException(SR.Xml_EmptyName);
            }
            int colonPos;
            int len = ValidateNames.ParseQName(name, 0, out colonPos);

            if (len != name.Length)
            {
                string res = (len == 0 || (colonPos > -1 && len == colonPos + 1)) ? SR.Xml_BadStartNameChar : SR.Xml_BadNameChar;
                throw new ArgumentException(string.Format(res, XmlException.BuildCharExceptionArgs(name, len)));
            }
        }
        private void ValidateQName(string name)
        {
            if (name.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.Xml_EmptyName));
            }
            int colonPos;
            int len = ValidateNames.ParseQName(name, 0, out colonPos);

            if (len != name.Length)
            {
                string res = (len == 0 || (colonPos > -1 && len == colonPos + 1)) ? Res.Xml_BadStartNameChar : Res.Xml_BadNameChar;
                throw new ArgumentException(Res.GetString(res, XmlException.BuildCharExceptionStr(name[len])));
            }
        }
        private void ValidateQName(string name)
        {
            int num;

            if (name.Length == 0)
            {
                throw new ArgumentException(Res.GetString("Xml_EmptyName"));
            }
            int invCharIndex = ValidateNames.ParseQName(name, 0, out num);

            if (invCharIndex != name.Length)
            {
                string str = ((invCharIndex == 0) || ((num > -1) && (invCharIndex == (num + 1)))) ? "Xml_BadStartNameChar" : "Xml_BadNameChar";
                throw new ArgumentException(Res.GetString(str, XmlException.BuildCharExceptionArgs(name, invCharIndex)));
            }
        }
Esempio n. 4
0
        public static string VerifyQName(string name, ExceptionType exceptionType)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            int colonPosition = -1;

            int endPos = ValidateNames.ParseQName(name, 0, out colonPosition);

            if (endPos != name.Length)
            {
                throw CreateException(SR.Xml_BadNameChar, XmlExceptionHelper.BuildCharExceptionArgs(name, endPos), exceptionType, 0, endPos + 1);
            }
            return(name);
        }
Esempio n. 5
0
        internal static string VerifyQName(string name, ExceptionType exceptionType)
        {
            if (name == null || name.Length == 0)
            {
                throw new ArgumentNullException(nameof(name));
            }

            int colonPosition = -1;

            int endPos = ValidateNames.ParseQName(name, 0, out colonPosition);

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