Пример #1
0
        public static string VerifyTOKEN(string token)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }

            if (token.Length == 0)
            {
                return(token);
            }

            if (XmlChar.IsWhitespace(token [0]) ||
                XmlChar.IsWhitespace(token [token.Length - 1]))
            {
                throw new XmlException("Whitespace characters (#xA, #xD, #x9, #x20) are not allowed as leading or trailing whitespaces of xs:token.");
            }

            for (int i = 0; i < token.Length; i++)
            {
                if (XmlChar.IsWhitespace(token [i]) && token [i] != ' ')
                {
                    throw new XmlException("Either #xA, #xD or #x9 are not allowed inside xs:token.");
                }
            }

            return(token);
        }
Пример #2
0
        internal static string VerifyTOKEN(string name)
#endif
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (name.Length == 0)
            {
                return(name);
            }

            if (XmlChar.IsWhitespace(name [0]) ||
                XmlChar.IsWhitespace(name [name.Length - 1]))
            {
                throw new XmlException("Whitespace characters (#xA, #xD, #x9, #x20) are not allowed as leading or trailing whitespaces of xs:token.");
            }

            for (int i = 0; i < name.Length; i++)
            {
                if (XmlChar.IsWhitespace(name [i]) && name [i] != ' ')
                {
                    throw new XmlException("Either #xA, #xD or #x9 are not allowed inside xs:token.");
                }
            }

            return(name);
        }
Пример #3
0
        public virtual XmlWhitespace CreateWhitespace(string text)
        {
            if (!XmlChar.IsWhitespace(text))
            {
                throw new ArgumentException("Invalid whitespace characters.");
            }

            return(new XmlWhitespace(text, this));
        }
Пример #4
0
 private int SkipIgnorableBase64Chars(char [] chars, int charsLength, int i)
 {
     while (chars [i] == '=' || XmlChar.IsWhitespace(chars [i]))
     {
         if (charsLength == ++i)
         {
             break;
         }
     }
     return(i);
 }
Пример #5
0
 public static int IndexOfNonWhitespace(string str)
 {
     for (int i = 0; i < str.Length; i++)
     {
         if (!XmlChar.IsWhitespace((int)str[i]))
         {
             return(i);
         }
     }
     return(-1);
 }
Пример #6
0
 public static bool IsWhitespace(string str)
 {
     for (int i = 0; i < str.Length; i++)
     {
         if (!XmlChar.IsWhitespace((int)str[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #7
0
 public static string VerifyWhitespace(string content)
 {
     if (content == null)
     {
         throw new ArgumentNullException("content");
     }
     if (XmlChar.IsWhitespace(content))
     {
         return(content);
     }
     throw new XmlException(string.Format("'{0}' is not whitespace", content));
 }
Пример #8
0
 private int SkipWhitespace(string input, int index)
 {
     while (index < input.Length)
     {
         if (!XmlChar.IsWhitespace((int)input[index]))
         {
             break;
         }
         index++;
     }
     return(index);
 }
Пример #9
0
        void ParseInput(string input)
        {
            int index = SkipWhitespace(input, 0);

            if (index + 7 > input.Length || input.IndexOf("version", index, 7) != index)
            {
                throw new XmlException("Missing 'version' specification.");
            }
            index = SkipWhitespace(input, index + 7);

            char c = input [index];

            if (c != '=')
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            index++;
            index = SkipWhitespace(input, index);
            c     = input [index];
            if (c != '"' && c != '\'')
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            index++;
            int end = input.IndexOf(c, index);

            if (end < 0 || input.IndexOf("1.0", index, 3) != index)
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            index += 4;
            if (index == input.Length)
            {
                return;
            }
            if (!XmlChar.IsWhitespace(input [index]))
            {
                throw new XmlException("Invalid XML declaration.");
            }
            index = SkipWhitespace(input, index + 1);
            if (index == input.Length)
            {
                return;
            }

            if (input.Length > index + 8 && input.IndexOf("encoding", index, 8) > 0)
            {
                index = SkipWhitespace(input, index + 8);
                c     = input [index];
                if (c != '=')
                {
                    throw new XmlException("Invalid 'version' specification.");
                }
                index++;
                index = SkipWhitespace(input, index);
                c     = input [index];
                if (c != '"' && c != '\'')
                {
                    throw new XmlException("Invalid 'encoding' specification.");
                }
                end = input.IndexOf(c, index + 1);
                if (end < 0)
                {
                    throw new XmlException("Invalid 'encoding' specification.");
                }
                Encoding = input.Substring(index + 1, end - index - 1);
                index    = end + 1;
                if (index == input.Length)
                {
                    return;
                }
                if (!XmlChar.IsWhitespace(input [index]))
                {
                    throw new XmlException("Invalid XML declaration.");
                }
                index = SkipWhitespace(input, index + 1);
            }

            if (input.Length > index + 10 && input.IndexOf("standalone", index, 10) > 0)
            {
                index = SkipWhitespace(input, index + 10);
                c     = input [index];
                if (c != '=')
                {
                    throw new XmlException("Invalid 'version' specification.");
                }
                index++;
                index = SkipWhitespace(input, index);
                c     = input [index];
                if (c != '"' && c != '\'')
                {
                    throw new XmlException("Invalid 'standalone' specification.");
                }
                end = input.IndexOf(c, index + 1);
                if (end < 0)
                {
                    throw new XmlException("Invalid 'standalone' specification.");
                }
                string tmp = input.Substring(index + 1, end - index - 1);
                switch (tmp)
                {
                case "yes":
                case "no":
                    break;

                default:
                    throw new XmlException("Invalid standalone specification.");
                }
                Standalone = tmp;
                index      = end + 1;
                index      = SkipWhitespace(input, index);
            }
            if (index != input.Length)
            {
                throw new XmlException("Invalid XML declaration.");
            }
        }
Пример #10
0
 public static bool IsWhitespaceChar(char ch)
 {
     return(XmlChar.IsWhitespace(ch));
 }
Пример #11
0
 public static bool IsPubidChar(int ch)
 {
     return((XmlChar.IsWhitespace(ch) && ch != 9) | (97 <= ch && ch <= 122) | (65 <= ch && ch <= 90) | (48 <= ch && ch <= 57) | "-'()+,./:=?;!*#@$_%".IndexOf((char)ch) >= 0);
 }
Пример #12
0
        private void ParseInput(string input)
        {
            int num = this.SkipWhitespace(input, 0);

            if (num + 7 > input.Length || input.IndexOf("version", num, 7) != num)
            {
                throw new XmlException("Missing 'version' specification.");
            }
            num = this.SkipWhitespace(input, num + 7);
            char c = input[num];

            if (c != '=')
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            num++;
            num = this.SkipWhitespace(input, num);
            c   = input[num];
            if (c != '"' && c != '\'')
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            num++;
            int num2 = input.IndexOf(c, num);

            if (num2 < 0 || input.IndexOf("1.0", num, 3) != num)
            {
                throw new XmlException("Invalid 'version' specification.");
            }
            num += 4;
            if (num == input.Length)
            {
                return;
            }
            if (!XmlChar.IsWhitespace((int)input[num]))
            {
                throw new XmlException("Invalid XML declaration.");
            }
            num = this.SkipWhitespace(input, num + 1);
            if (num == input.Length)
            {
                return;
            }
            if (input.Length > num + 8 && input.IndexOf("encoding", num, 8) > 0)
            {
                num = this.SkipWhitespace(input, num + 8);
                c   = input[num];
                if (c != '=')
                {
                    throw new XmlException("Invalid 'version' specification.");
                }
                num++;
                num = this.SkipWhitespace(input, num);
                c   = input[num];
                if (c != '"' && c != '\'')
                {
                    throw new XmlException("Invalid 'encoding' specification.");
                }
                num2 = input.IndexOf(c, num + 1);
                if (num2 < 0)
                {
                    throw new XmlException("Invalid 'encoding' specification.");
                }
                this.Encoding = input.Substring(num + 1, num2 - num - 1);
                num           = num2 + 1;
                if (num == input.Length)
                {
                    return;
                }
                if (!XmlChar.IsWhitespace((int)input[num]))
                {
                    throw new XmlException("Invalid XML declaration.");
                }
                num = this.SkipWhitespace(input, num + 1);
            }
            if (input.Length > num + 10 && input.IndexOf("standalone", num, 10) > 0)
            {
                num = this.SkipWhitespace(input, num + 10);
                c   = input[num];
                if (c != '=')
                {
                    throw new XmlException("Invalid 'version' specification.");
                }
                num++;
                num = this.SkipWhitespace(input, num);
                c   = input[num];
                if (c != '"' && c != '\'')
                {
                    throw new XmlException("Invalid 'standalone' specification.");
                }
                num2 = input.IndexOf(c, num + 1);
                if (num2 < 0)
                {
                    throw new XmlException("Invalid 'standalone' specification.");
                }
                string text  = input.Substring(num + 1, num2 - num - 1);
                string text2 = text;
                if (text2 != null)
                {
                    if (XmlDeclaration.< > f__switch$map4A == null)
                    {
                        XmlDeclaration.< > f__switch$map4A = new Dictionary <string, int>(2)
                        {
                            {
                                "yes",
                                0
                            },
                            {
                                "no",
                                0
                            }
                        };
                    }
                    int num3;
                    if (XmlDeclaration.< > f__switch$map4A.TryGetValue(text2, out num3))
                    {
                        if (num3 == 0)
                        {
                            this.Standalone = text;
                            num             = num2 + 1;
                            num             = this.SkipWhitespace(input, num);
                            goto IL_308;
                        }
                    }
                }
                throw new XmlException("Invalid standalone specification.");
            }
IL_308:
            if (num != input.Length)
            {
                throw new XmlException("Invalid XML declaration.");
            }
        }