Beispiel #1
0
        private void ParseContents()
        {
            TokenizerStream stream = new TokenizerStream();

            this._t.GetTokens(stream, 2, false);
            stream.Reset();
            int format = this.DetermineFormat(stream);

            stream.GoToPosition(format);
            this._t.GetTokens(stream, -1, false);
            stream.Reset();
            int index = 0;

            this.GetRequiredSizes(stream, ref index);
            this._doc = new SecurityDocument(index);
            int position = 0;

            stream.Reset();
            for (short nextFullToken = stream.GetNextFullToken(); (int)nextFullToken != -1; nextFullToken = stream.GetNextFullToken())
            {
                if (((int)nextFullToken & 16384) == 16384)
                {
                    switch ((short)((int)nextFullToken & 65280))
                    {
                    case 17408:
                        this._doc.AddToken((byte)4, ref position);
                        continue;

                    case 20480:
                        stream.ThrowAwayNextString();
                        continue;

                    case 25344:
                        this._doc.AppendString(" ", ref position);
                        this._doc.AppendString(stream.GetNextString(), ref position);
                        continue;

                    case 16640:
                        this._doc.AddToken((byte)1, ref position);
                        this._doc.AddString(stream.GetNextString(), ref position);
                        continue;

                    case 16896:
                        this._doc.AddToken((byte)2, ref position);
                        this._doc.AddString(stream.GetNextString(), ref position);
                        this._doc.AddString(stream.GetNextString(), ref position);
                        continue;

                    case 17152:
                        this._doc.AddToken((byte)3, ref position);
                        this._doc.AddString(stream.GetNextString(), ref position);
                        continue;

                    default:
                        throw new XmlSyntaxException();
                    }
                }
            }
        }
        private int DetermineFormat(TokenizerStream stream)
        {
            if (stream.GetNextToken() == Tokenizer.bra)
            {
                if (stream.GetNextToken() == Tokenizer.quest)
                {
                    _t.GetTokens(stream, -1, true);
                    stream.GoToPosition(2);

                    bool sawEquals   = false;
                    bool sawEncoding = false;

                    short i;

                    for (i = stream.GetNextToken(); i != -1 && i != Tokenizer.ket; i = stream.GetNextToken())
                    {
                        switch (i)
                        {
                        case Tokenizer.cstr:
                            if (sawEquals && sawEncoding)
                            {
                                _t.ChangeFormat(System.Text.Encoding.GetEncoding(stream.GetNextString()));
                                return(0);
                            }
                            else if (!sawEquals)
                            {
                                if (String.Compare(stream.GetNextString(), "encoding", StringComparison.Ordinal) == 0)
                                {
                                    sawEncoding = true;
                                }
                            }
                            else
                            {
                                sawEquals   = false;
                                sawEncoding = false;
                                stream.ThrowAwayNextString();
                            }
                            break;

                        case Tokenizer.equals:
                            sawEquals = true;
                            break;

                        default:
                            throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }
                    }

                    return(0);
                }
            }

            return(2);
        }
        private int DetermineFormat(TokenizerStream stream)
        {
            if ((stream.GetNextToken() != 0) || (stream.GetNextToken() != 5))
            {
                return(2);
            }
            this._t.GetTokens(stream, -1, true);
            stream.GoToPosition(2);
            bool flag  = false;
            bool flag2 = false;

            for (short i = stream.GetNextToken(); (i != -1) && (i != 1); i = stream.GetNextToken())
            {
                switch (i)
                {
                case 3:
                    if (!flag || !flag2)
                    {
                        break;
                    }
                    this._t.ChangeFormat(Encoding.GetEncoding(stream.GetNextString()));
                    return(0);

                case 4:
                {
                    flag = true;
                    continue;
                }

                default:
                    throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
                if (!flag)
                {
                    if (string.Compare(stream.GetNextString(), "encoding", StringComparison.Ordinal) == 0)
                    {
                        flag2 = true;
                    }
                }
                else
                {
                    flag  = false;
                    flag2 = false;
                    stream.ThrowAwayNextString();
                }
            }
            return(0);
        }
 // Token: 0x06002B98 RID: 11160 RVA: 0x000A37B0 File Offset: 0x000A19B0
 private int DetermineFormat(TokenizerStream stream)
 {
     if (stream.GetNextToken() == 0 && stream.GetNextToken() == 5)
     {
         this._t.GetTokens(stream, -1, true);
         stream.GoToPosition(2);
         bool  flag      = false;
         bool  flag2     = false;
         short nextToken = stream.GetNextToken();
         while (nextToken != -1 && nextToken != 1)
         {
             if (nextToken != 3)
             {
                 if (nextToken != 4)
                 {
                     throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                 }
                 flag = true;
             }
             else
             {
                 if (flag && flag2)
                 {
                     this._t.ChangeFormat(Encoding.GetEncoding(stream.GetNextString()));
                     return(0);
                 }
                 if (!flag)
                 {
                     if (string.Compare(stream.GetNextString(), "encoding", StringComparison.Ordinal) == 0)
                     {
                         flag2 = true;
                     }
                 }
                 else
                 {
                     flag  = false;
                     flag2 = false;
                     stream.ThrowAwayNextString();
                 }
             }
             nextToken = stream.GetNextToken();
         }
         return(0);
     }
     return(2);
 }
        private int DetermineFormat(TokenizerStream stream)
        {
            if ((stream.GetNextToken() != 0) || (stream.GetNextToken() != 5))
            {
                return 2;
            }
            this._t.GetTokens(stream, -1, true);
            stream.GoToPosition(2);
            bool flag = false;
            bool flag2 = false;
            for (short i = stream.GetNextToken(); (i != -1) && (i != 1); i = stream.GetNextToken())
            {
                switch (i)
                {
                    case 3:
                        if (!flag || !flag2)
                        {
                            break;
                        }
                        this._t.ChangeFormat(Encoding.GetEncoding(stream.GetNextString()));
                        return 0;

                    case 4:
                    {
                        flag = true;
                        continue;
                    }
                    default:
                        throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
                if (!flag)
                {
                    if (string.Compare(stream.GetNextString(), "encoding", StringComparison.Ordinal) == 0)
                    {
                        flag2 = true;
                    }
                }
                else
                {
                    flag = false;
                    flag2 = false;
                    stream.ThrowAwayNextString();
                }
            }
            return 0;
        }
        // Token: 0x06002B99 RID: 11161 RVA: 0x000A3874 File Offset: 0x000A1A74
        private void ParseContents()
        {
            TokenizerStream tokenizerStream = new TokenizerStream();

            this._t.GetTokens(tokenizerStream, 2, false);
            tokenizerStream.Reset();
            int position = this.DetermineFormat(tokenizerStream);

            tokenizerStream.GoToPosition(position);
            this._t.GetTokens(tokenizerStream, -1, false);
            tokenizerStream.Reset();
            int numData = 0;

            this.GetRequiredSizes(tokenizerStream, ref numData);
            this._doc = new SecurityDocument(numData);
            int num = 0;

            tokenizerStream.Reset();
            for (short nextFullToken = tokenizerStream.GetNextFullToken(); nextFullToken != -1; nextFullToken = tokenizerStream.GetNextFullToken())
            {
                if ((nextFullToken & 16384) == 16384)
                {
                    short num2 = (short)((int)nextFullToken & 65280);
                    if (num2 <= 17152)
                    {
                        if (num2 == 16640)
                        {
                            this._doc.AddToken(1, ref num);
                            this._doc.AddString(tokenizerStream.GetNextString(), ref num);
                            goto IL_19D;
                        }
                        if (num2 == 16896)
                        {
                            this._doc.AddToken(2, ref num);
                            this._doc.AddString(tokenizerStream.GetNextString(), ref num);
                            this._doc.AddString(tokenizerStream.GetNextString(), ref num);
                            goto IL_19D;
                        }
                        if (num2 == 17152)
                        {
                            this._doc.AddToken(3, ref num);
                            this._doc.AddString(tokenizerStream.GetNextString(), ref num);
                            goto IL_19D;
                        }
                    }
                    else
                    {
                        if (num2 == 17408)
                        {
                            this._doc.AddToken(4, ref num);
                            goto IL_19D;
                        }
                        if (num2 == 20480)
                        {
                            tokenizerStream.ThrowAwayNextString();
                            goto IL_19D;
                        }
                        if (num2 == 25344)
                        {
                            this._doc.AppendString(" ", ref num);
                            this._doc.AppendString(tokenizerStream.GetNextString(), ref num);
                            goto IL_19D;
                        }
                    }
                    throw new XmlSyntaxException();
                }
                IL_19D :;
            }
        }
        // Token: 0x06002B97 RID: 11159 RVA: 0x000A3388 File Offset: 0x000A1588
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            int  num   = 1;
            SecurityElementType securityElementType = SecurityElementType.Regular;
            string text  = null;
            bool   flag5 = false;
            bool   flag6 = false;
            int    num2  = 0;

            for (;;)
            {
                short nextToken = stream.GetNextToken();
                while (nextToken != -1)
                {
                    switch (nextToken & 255)
                    {
                    case 0:
                        flag4     = true;
                        flag6     = false;
                        nextToken = stream.GetNextToken();
                        if (nextToken == 2)
                        {
                            stream.TagLastToken(17408);
                            for (;;)
                            {
                                nextToken = stream.GetNextToken();
                                if (nextToken != 3)
                                {
                                    break;
                                }
                                stream.ThrowAwayNextString();
                                stream.TagLastToken(20480);
                            }
                            if (nextToken == -1)
                            {
                                goto Block_9;
                            }
                            if (nextToken != 1)
                            {
                                goto Block_10;
                            }
                            flag4 = false;
                            index++;
                            flag6 = false;
                            num--;
                            flag = true;
                            goto IL_3B9;
                        }
                        else if (nextToken == 3)
                        {
                            flag3 = true;
                            stream.TagLastToken(16640);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            if (securityElementType != SecurityElementType.Regular)
                            {
                                goto Block_12;
                            }
                            flag = true;
                            num++;
                            goto IL_3B9;
                        }
                        else
                        {
                            if (nextToken == 6)
                            {
                                num2 = 1;
                                do
                                {
                                    nextToken = stream.GetNextToken();
                                    switch (nextToken)
                                    {
                                    case 0:
                                        num2++;
                                        break;

                                    case 1:
                                        num2--;
                                        break;

                                    case 3:
                                        stream.ThrowAwayNextString();
                                        stream.TagLastToken(20480);
                                        break;
                                    }
                                }while (num2 > 0);
                                flag4 = false;
                                flag6 = false;
                                flag  = true;
                                goto IL_3B9;
                            }
                            if (nextToken != 5)
                            {
                                goto IL_2B3;
                            }
                            nextToken = stream.GetNextToken();
                            if (nextToken != 3)
                            {
                                goto Block_17;
                            }
                            flag3 = true;
                            securityElementType = SecurityElementType.Format;
                            stream.TagLastToken(16640);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            num2   = 1;
                            num++;
                            flag = true;
                            goto IL_3B9;
                        }
                        break;

                    case 1:
                        if (flag4)
                        {
                            flag4 = false;
                            goto IL_3C4;
                        }
                        goto IL_2E0;

                    case 2:
                        nextToken = stream.GetNextToken();
                        if (nextToken == 1)
                        {
                            stream.TagLastToken(17408);
                            index++;
                            num--;
                            flag6 = false;
                            flag  = true;
                            goto IL_3B9;
                        }
                        goto IL_329;

                    case 3:
                        if (flag4)
                        {
                            if (securityElementType == SecurityElementType.Comment)
                            {
                                stream.ThrowAwayNextString();
                                stream.TagLastToken(20480);
                                goto IL_3B9;
                            }
                            if (text == null)
                            {
                                text = stream.GetNextString();
                                goto IL_3B9;
                            }
                            if (!flag5)
                            {
                                goto Block_5;
                            }
                            stream.TagLastToken(16896);
                            index += SecurityDocument.EncodedStringSize(text) + SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            text   = null;
                            flag5  = false;
                            goto IL_3B9;
                        }
                        else
                        {
                            if (flag6)
                            {
                                stream.TagLastToken(25344);
                                index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" ");
                                goto IL_3B9;
                            }
                            stream.TagLastToken(17152);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            flag6  = true;
                            goto IL_3B9;
                        }
                        break;

                    case 4:
                        flag5 = true;
                        goto IL_3B9;

                    case 5:
                        if (!flag4 || securityElementType != SecurityElementType.Format || num2 != 1)
                        {
                            goto IL_397;
                        }
                        nextToken = stream.GetNextToken();
                        if (nextToken == 1)
                        {
                            stream.TagLastToken(17408);
                            index++;
                            num--;
                            flag6 = false;
                            flag  = true;
                            goto IL_3B9;
                        }
                        goto IL_37C;
                    }
                    goto Block_1;
IL_3C4:
                    nextToken = stream.GetNextToken();
                    continue;
IL_3B9:
                    if (flag)
                    {
                        flag  = false;
                        flag2 = false;
                        break;
                    }
                    flag2 = true;
                    goto IL_3C4;
                }
                if (flag2)
                {
                    index++;
                    num--;
                    flag6 = false;
                }
                else if (nextToken == -1 && (num != 1 || !flag3))
                {
                    goto IL_3F5;
                }
                if (num <= 1)
                {
                    return;
                }
            }
Block_1:
            goto IL_3A8;
Block_5:
            throw new XmlSyntaxException(this._t.LineNo);
Block_9:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_10:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
Block_12:
            throw new XmlSyntaxException(this._t.LineNo);
Block_17:
            throw new XmlSyntaxException(this._t.LineNo);
IL_2B3:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString"));
IL_2E0:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket"));
IL_329:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
IL_37C:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
IL_397:
            throw new XmlSyntaxException(this._t.LineNo);
IL_3A8:
            throw new XmlSyntaxException(this._t.LineNo);
IL_3F5:
            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
        }
Beispiel #8
0
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num1  = 0;
                bool flag1 = false;
                bool flag2 = false;
                Tokenizer.StringMaker stringMaker1 = this._maker;
                stringMaker1._outStringBuilder = (StringBuilder)null;
                stringMaker1._outIndex         = 0;
                int num2;
                while (true)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 < this._inSize)
                            {
                                num2          = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                                this._inIndex = this._inIndex + 2;
                                break;
                            }
                            goto label_6;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray1 = this._inBytes;
                                int    num3      = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)numArray1[index1];
                                if ((num2 & 128) != 0)
                                {
                                    switch ((num2 & 240) >> 4)
                                    {
                                    case 8:
                                    case 9:
                                    case 10:
                                    case 11:
                                        goto label_12;

                                    case 12:
                                    case 13:
                                        num2 &= 31;
                                        num1  = 2;
                                        break;

                                    case 14:
                                        num2 &= 15;
                                        num1  = 3;
                                        break;

                                    case 15:
                                        goto label_15;
                                    }
                                    if (this._inIndex < this._inSize)
                                    {
                                        byte[] numArray2 = this._inBytes;
                                        int    num4      = this._inIndex;
                                        this._inIndex = num4 + 1;
                                        int  index2 = num4;
                                        byte num5   = numArray2[index2];
                                        if (((int)num5 & 192) == 128)
                                        {
                                            num2 = num2 << 6 | (int)num5 & 63;
                                            if (num1 != 2)
                                            {
                                                if (this._inIndex < this._inSize)
                                                {
                                                    byte[] numArray3 = this._inBytes;
                                                    int    num6      = this._inIndex;
                                                    this._inIndex = num6 + 1;
                                                    int  index3 = num6;
                                                    byte num7   = numArray3[index3];
                                                    if (((int)num7 & 192) == 128)
                                                    {
                                                        num2 = num2 << 6 | (int)num7 & 63;
                                                        break;
                                                    }
                                                    goto label_24;
                                                }
                                                else
                                                {
                                                    goto label_22;
                                                }
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            goto label_19;
                                        }
                                    }
                                    else
                                    {
                                        goto label_17;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                goto label_9;
                            }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray = this._inBytes;
                                int    num3     = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)numArray[index];
                                break;
                            }
                            goto label_27;

                        case Tokenizer.TokenSource.CharArray:
                            if (this._inIndex < this._inSize)
                            {
                                char[] chArray = this._inChars;
                                int    num3    = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)chArray[index];
                                break;
                            }
                            goto label_30;

                        case Tokenizer.TokenSource.String:
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)str[index];
                                break;
                            }
                            goto label_33;

                        case Tokenizer.TokenSource.NestedStrings:
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string str  = this._inNestedString;
                                    int    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    int index = num3;
                                    num2 = (int)str[index];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)str[index1];
                                if (num2 == 123)
                                {
                                    for (int index2 = 0; index2 < this._searchStrings.Length; ++index2)
                                    {
                                        if (string.Compare(this._searchStrings[index2], 0, this._inString, this._inIndex - 1, this._searchStrings[index2].Length, StringComparison.Ordinal) == 0)
                                        {
                                            this._inNestedString = this._replaceStrings[index2];
                                            this._inNestedSize   = this._inNestedString.Length;
                                            this._inNestedIndex  = 1;
                                            num2          = (int)this._inNestedString[0];
                                            this._inIndex = this._inIndex + (this._searchStrings[index2].Length - 1);
                                            break;
                                        }
                                    }
                                    break;
                                }
                                break;
                            }
                            goto label_40;

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 != -1)
                            {
                                break;
                            }
                            goto label_48;
                        }
                    }
                    if (!flag1)
                    {
                        switch (num2)
                        {
                        case 45:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_63;

                        case 47:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_57;

                        case 60:
                            goto label_52;

                        case 61:
                            goto label_55;

                        case 62:
                            goto label_53;

                        case 63:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_59;

                        case 9:
                        case 13:
                        case 32:
                            continue;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            continue;

                        case 33:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_61;

                        case 34:
                            flag1 = true;
                            flag2 = true;
                            continue;
                        }
                    }
                    else
                    {
                        switch (num2)
                        {
                        case 34:
                            if (!flag2)
                            {
                                break;
                            }
                            goto label_72;

                        case 47:
                        case 61:
                        case 62:
                            if (flag2 || this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_70;

                        case 60:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_68;

                        case 9:
                        case 13:
                        case 32:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_74;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            if (flag2)
                            {
                                break;
                            }
                            goto label_76;
                        }
                    }
                    flag1 = true;
                    if (stringMaker1._outIndex < 512)
                    {
                        char[] chArray = stringMaker1._outChars;
                        Tokenizer.StringMaker stringMaker2 = stringMaker1;
                        int num3 = stringMaker2._outIndex;
                        int num4 = num3 + 1;
                        stringMaker2._outIndex = num4;
                        int index = num3;
                        int num5  = (int)(ushort)num2;
                        chArray[index] = (char)num5;
                    }
                    else
                    {
                        if (stringMaker1._outStringBuilder == null)
                        {
                            stringMaker1._outStringBuilder = new StringBuilder();
                        }
                        stringMaker1._outStringBuilder.Append(stringMaker1._outChars, 0, 512);
                        stringMaker1._outChars[0] = (char)num2;
                        stringMaker1._outIndex    = 1;
                    }
                }
label_6:
                stream.AddToken((short)-1);
                break;
label_9:
                stream.AddToken((short)-1);
                break;
label_12:
                throw new XmlSyntaxException(this.LineNo);
label_15:
                throw new XmlSyntaxException(this.LineNo);
label_17:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_19:
                throw new XmlSyntaxException(this.LineNo);
label_22:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_24:
                throw new XmlSyntaxException(this.LineNo);
label_27:
                stream.AddToken((short)-1);
                break;
label_30:
                stream.AddToken((short)-1);
                break;
label_33:
                stream.AddToken((short)-1);
                break;
label_40:
                stream.AddToken((short)-1);
                break;
label_48:
                stream.AddToken((short)-1);
                break;
label_52:
                this._inProcessingTag = this._inProcessingTag + 1;
                stream.AddToken((short)0);
                continue;
label_53:
                this._inProcessingTag = this._inProcessingTag - 1;
                stream.AddToken((short)1);
                if (endAfterKet)
                {
                    break;
                }
                continue;
label_55:
                stream.AddToken((short)4);
                continue;
label_57:
                stream.AddToken((short)2);
                continue;
label_59:
                stream.AddToken((short)5);
                continue;
label_61:
                stream.AddToken((short)6);
                continue;
label_63:
                stream.AddToken((short)7);
                continue;
label_68:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_70:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_72:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_74:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_76:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
            }
        }
 private void ParseContents()
 {
     TokenizerStream stream = new TokenizerStream();
     this._t.GetTokens(stream, 2, false);
     stream.Reset();
     int position = this.DetermineFormat(stream);
     stream.GoToPosition(position);
     this._t.GetTokens(stream, -1, false);
     stream.Reset();
     int index = 0;
     this.GetRequiredSizes(stream, ref index);
     this._doc = new SecurityDocument(index);
     int num4 = 0;
     stream.Reset();
     for (short i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken())
     {
         if ((i & 0x4000) == 0x4000)
         {
             switch (((short) (i & 0xff00)))
             {
                 case 0x4400:
                 {
                     this._doc.AddToken(4, ref num4);
                     continue;
                 }
                 case 0x5000:
                 {
                     stream.ThrowAwayNextString();
                     continue;
                 }
                 case 0x6300:
                 {
                     this._doc.AppendString(" ", ref num4);
                     this._doc.AppendString(stream.GetNextString(), ref num4);
                     continue;
                 }
                 case 0x4100:
                 {
                     this._doc.AddToken(1, ref num4);
                     this._doc.AddString(stream.GetNextString(), ref num4);
                     continue;
                 }
                 case 0x4200:
                 {
                     this._doc.AddToken(2, ref num4);
                     this._doc.AddString(stream.GetNextString(), ref num4);
                     this._doc.AddString(stream.GetNextString(), ref num4);
                     continue;
                 }
                 case 0x4300:
                 {
                     this._doc.AddToken(3, ref num4);
                     this._doc.AddString(stream.GetNextString(), ref num4);
                     continue;
                 }
             }
             throw new XmlSyntaxException();
         }
     }
 }
Beispiel #10
0
        private void GetRequiredSizes( TokenizerStream stream, ref int index ) 
        {
            //
            // Iteratively collect stuff up until the next end-tag.
            // We've already seen the open-tag. 
            //
 
            bool needToBreak = false; 
            bool needToPop = false;
            bool createdNode = false; 
            bool intag = false;
            int stackDepth = 1;
            SecurityElementType type = SecurityElementType.Regular;
            String strValue = null; 
            bool sawEquals = false;
            bool sawText = false; 
            int status = 0; 

            short i; 

            do
            {
                for (i = stream.GetNextToken() ; i != -1 ; i = stream.GetNextToken()) 
                {
                    switch (i & 0x00FF) 
                    { 
                    case Tokenizer.cstr:
                        { 
                            if (intag)
                            {
                                if (type == SecurityElementType.Comment)
                                { 
                                    // Ignore data in comments but still get the data
                                    // to keep the stream in the right place. 
                                    stream.ThrowAwayNextString(); 
                                    stream.TagLastToken( c_wastedstringtag );
                                } 
                                else
                                {
                                    // We're in a regular tag, so we've found an attribute/value pair.
 
                                    if (strValue == null)
                                    { 
                                        // Found attribute name, save it for later. 

                                        strValue = stream.GetNextString(); 
                                    }
                                    else
                                    {
                                        // Found attribute text, add the pair to the current element. 

                                        if (!sawEquals) 
                                            throw new XmlSyntaxException( _t.LineNo ); 

                                        stream.TagLastToken( c_attributetag ); 
                                        index += SecurityDocument.EncodedStringSize( strValue ) +
                                                 SecurityDocument.EncodedStringSize( stream.GetNextString() ) +
                                                 1;
                                        strValue = null; 
                                        sawEquals = false;
                                    } 
                                } 
                            }
                            else 
                            {
                                // We're not in a tag, so we've found text between tags.

                                if (sawText) 
                                {
                                    stream.TagLastToken( c_additionaltexttag ); 
                                    index += SecurityDocument.EncodedStringSize( stream.GetNextString() ) + 
                                             SecurityDocument.EncodedStringSize( " " );
                                } 
                                else
                                {
                                    stream.TagLastToken( c_texttag );
                                    index += SecurityDocument.EncodedStringSize( stream.GetNextString() ) + 
                                             1;
                                    sawText = true; 
                                } 
                            }
                        } 
                        break;

                    case Tokenizer.bra:
                        intag = true; 
                        sawText = false;
                        i = stream.GetNextToken(); 
 
                        if (i == Tokenizer.slash)
                        { 
                            stream.TagLastToken( c_childrentag );
                            while (true)
                            {
                                // spin; don't care what's in here 
                                i = stream.GetNextToken();
                                if (i == Tokenizer.cstr) 
                                { 
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken( c_wastedstringtag ); 
                                }
                                else if (i == -1)
                                    throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));
                                else 
                                    break;
                            } 
 
                            if (i != Tokenizer.ket)
                            { 
                                throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_ExpectedCloseBracket" ));
                            }

                            intag = false; 

                            // Found the end of this element 
                            index++; 

                            sawText = false; 
                            stackDepth--;

                            needToBreak = true;
                        } 
                        else if (i == Tokenizer.cstr)
                        { 
                            // Found a child 

                            createdNode = true; 

                            stream.TagLastToken( c_elementtag );
                            index += SecurityDocument.EncodedStringSize( stream.GetNextString() ) +
                                     1; 

                            if (type != SecurityElementType.Regular) 
                                throw new XmlSyntaxException( _t.LineNo ); 

                            needToBreak = true; 
                            stackDepth++;
                        }
                        else if (i == Tokenizer.bang)
                        { 
                            // Found a child that is a comment node.  Next up better be a cstr.
 
                            status = 1; 

                            do 
                            {
                                i = stream.GetNextToken();

                                switch (i) 
                                {
                                case Tokenizer.bra: 
                                    status++; 
                                    break;
 
                                case Tokenizer.ket:
                                    status--;
                                    break;
 
                                case Tokenizer.cstr:
                                    stream.ThrowAwayNextString(); 
                                    stream.TagLastToken( c_wastedstringtag ); 
                                    break;
 
                                default:
                                    break;
                                }
                            } while (status > 0); 

                            intag = false; 
                            sawText = false; 
                            needToBreak = true;
                        } 
                        else if (i == Tokenizer.quest)
                        {
                            // Found a child that is a format node.  Next up better be a cstr.
 
                            i = stream.GetNextToken();
 
                            if (i != Tokenizer.cstr) 
                                throw new XmlSyntaxException( _t.LineNo );
 
                            createdNode = true;

                            type = SecurityElementType.Format;
 
                            stream.TagLastToken( c_elementtag );
                            index += SecurityDocument.EncodedStringSize( stream.GetNextString() ) + 
                                     1; 

                            status = 1; 
                            stackDepth++;

                            needToBreak = true;
                        } 
                        else
                        { 
                            throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_ExpectedSlashOrString" )); 
                        }
                        break ; 

                    case Tokenizer.equals:
                        sawEquals = true;
                        break; 

                    case Tokenizer.ket: 
                        if (intag) 
                        {
                            intag = false; 
                            continue;
                        }
                        else
                        { 
                            throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedCloseBracket" ));
                        } 
                        // not reachable 

                    case Tokenizer.slash: 
                        i = stream.GetNextToken();

                        if (i == Tokenizer.ket)
                        { 
                            // Found the end of this element
                            stream.TagLastToken( c_childrentag ); 
                            index++; 
                            stackDepth--;
                            sawText = false; 

                            needToBreak = true;
                        }
                        else 
                        {
                            throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_ExpectedCloseBracket" )); 
                        } 
                        break;
 
                    case Tokenizer.quest:
                        if (intag && type == SecurityElementType.Format && status == 1)
                        {
                            i = stream.GetNextToken(); 

                            if (i == Tokenizer.ket) 
                            { 
                                stream.TagLastToken( c_childrentag );
                                index++; 
                                stackDepth--;
                                sawText = false;

                                needToBreak = true; 
                            }
                            else 
                            { 
                                throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_ExpectedCloseBracket" ));
                            } 
                        }
                        else
                        {
                            throw new XmlSyntaxException (_t.LineNo); 
                        }
                        break; 
 
                    case Tokenizer.dash:
                    default: 
                        throw new XmlSyntaxException (_t.LineNo) ;
                    }

                    if (needToBreak) 
                    {
                        needToBreak = false; 
                        needToPop = false; 
                        break;
                    } 
                    else
                    {
                        needToPop = true;
                    } 
                }
 
                if (needToPop) 
                {
                    index++; 
                    stackDepth--;
                    sawText = false;
                }
                else if (i == -1 && (stackDepth != 1 || !createdNode)) 
                {
                    // This means that we still have items on the stack, but the end of our 
                    // stream has been reached. 

                    throw new XmlSyntaxException( _t.LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" )); 
                }
            }
            while (stackDepth > 1);
        } 
Beispiel #11
0
        private int DetermineFormat( TokenizerStream stream ) 
        { 
            if (stream.GetNextToken() == Tokenizer.bra)
            { 
                if (stream.GetNextToken() == Tokenizer.quest)
                {
                    _t.GetTokens( stream, -1, true );
                    stream.GoToPosition( 2 ); 

                    bool sawEquals = false; 
                    bool sawEncoding = false; 

                    short i; 

                    for (i = stream.GetNextToken(); i != -1 && i != Tokenizer.ket; i = stream.GetNextToken())
                    {
                        switch (i) 
                        {
                        case Tokenizer.cstr: 
                            if (sawEquals && sawEncoding) 
                            {
                                _t.ChangeFormat( System.Text.Encoding.GetEncoding( stream.GetNextString() ) ); 
                                return 0;
                            }
                            else if (!sawEquals)
                            { 
                                if (String.Compare( stream.GetNextString(), "encoding", StringComparison.Ordinal) == 0)
                                    sawEncoding = true; 
                            } 
                            else
                            { 
                                sawEquals = false;
                                sawEncoding = false;
                                stream.ThrowAwayNextString();
                            } 
                            break;
 
                        case Tokenizer.equals: 
                            sawEquals = true;
                            break; 

                        default:
                            throw new XmlSyntaxException (_t.LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));
                        } 
                    }
 
                    return 0; 
                }
            } 

            return 2;
        }
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            int  num   = 1;
            SecurityElementType regular = SecurityElementType.Regular;
            string nextString           = null;
            bool   flag5 = false;
            bool   flag6 = false;
            int    num2  = 0;

            do
            {
                short nextToken = stream.GetNextToken();
                while (nextToken != -1)
                {
                    switch ((nextToken & 0xff))
                    {
                    case 0:
                        flag4     = true;
                        flag6     = false;
                        nextToken = stream.GetNextToken();
                        if (nextToken != 2)
                        {
                            goto Label_01BD;
                        }
                        stream.TagLastToken(0x4400);
                        while (true)
                        {
                            nextToken = stream.GetNextToken();
                            if (nextToken != 3)
                            {
                                break;
                            }
                            stream.ThrowAwayNextString();
                            stream.TagLastToken(0x5000);
                        }
                        if (nextToken == -1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }
                        if (nextToken != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        flag4 = false;
                        index++;
                        flag6 = false;
                        num--;
                        flag = true;
                        goto Label_03BD;

                    case 1:
                        if (!flag4)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket"));
                        }
                        flag4 = false;
                        goto Label_03C8;

                    case 2:
                        nextToken = stream.GetNextToken();
                        if (nextToken != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        stream.TagLastToken(0x4400);
                        index++;
                        num--;
                        flag6 = false;
                        flag  = true;
                        goto Label_03BD;

                    case 3:
                        if (!flag4)
                        {
                            goto Label_00D1;
                        }
                        if (regular != SecurityElementType.Comment)
                        {
                            break;
                        }
                        stream.ThrowAwayNextString();
                        stream.TagLastToken(0x5000);
                        goto Label_03BD;

                    case 4:
                        flag5 = true;
                        goto Label_03BD;

                    case 5:
                        if ((!flag4 || (regular != SecurityElementType.Format)) || (num2 != 1))
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        nextToken = stream.GetNextToken();
                        if (nextToken != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        stream.TagLastToken(0x4400);
                        index++;
                        num--;
                        flag6 = false;
                        flag  = true;
                        goto Label_03BD;

                    default:
                        throw new XmlSyntaxException(this._t.LineNo);
                    }
                    if (nextString == null)
                    {
                        nextString = stream.GetNextString();
                    }
                    else
                    {
                        if (!flag5)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        stream.TagLastToken(0x4200);
                        index     += (SecurityDocument.EncodedStringSize(nextString) + SecurityDocument.EncodedStringSize(stream.GetNextString())) + 1;
                        nextString = null;
                        flag5      = false;
                    }
                    goto Label_03BD;
Label_00D1:
                    if (flag6)
                    {
                        stream.TagLastToken(0x6300);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" ");
                    }
                    else
                    {
                        stream.TagLastToken(0x4300);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        flag6  = true;
                    }
                    goto Label_03BD;
Label_01BD:
                    if (nextToken == 3)
                    {
                        flag3 = true;
                        stream.TagLastToken(0x4100);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        if (regular != SecurityElementType.Regular)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        flag = true;
                        num++;
                    }
                    else if (nextToken == 6)
                    {
                        num2 = 1;
                        do
                        {
                            nextToken = stream.GetNextToken();
                            switch (nextToken)
                            {
                            case 0:
                                num2++;
                                break;

                            case 1:
                                num2--;
                                break;

                            case 3:
                                stream.ThrowAwayNextString();
                                stream.TagLastToken(0x5000);
                                break;
                            }
                        }while (num2 > 0);
                        flag4 = false;
                        flag6 = false;
                        flag  = true;
                    }
                    else
                    {
                        if (nextToken != 5)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString"));
                        }
                        nextToken = stream.GetNextToken();
                        if (nextToken != 3)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        flag3   = true;
                        regular = SecurityElementType.Format;
                        stream.TagLastToken(0x4100);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        num2   = 1;
                        num++;
                        flag = true;
                    }
Label_03BD:
                    if (flag)
                    {
                        flag  = false;
                        flag2 = false;
                        break;
                    }
                    flag2 = true;
Label_03C8:
                    nextToken = stream.GetNextToken();
                }
                if (flag2)
                {
                    index++;
                    num--;
                    flag6 = false;
                }
                else if ((nextToken == -1) && ((num != 1) || !flag3))
                {
                    throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
            }while (num > 1);
        }
Beispiel #13
0
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            bool flag1 = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            int  num1  = 1;
            SecurityElementType securityElementType = SecurityElementType.Regular;
            string str   = (string)null;
            bool   flag5 = false;
            bool   flag6 = false;
            int    num2  = 0;

            do
            {
                short nextToken;
                for (nextToken = stream.GetNextToken(); (int)nextToken != -1; nextToken = stream.GetNextToken())
                {
                    switch ((int)nextToken & (int)byte.MaxValue)
                    {
                    case 0:
                        flag4     = true;
                        flag6     = false;
                        nextToken = stream.GetNextToken();
                        switch (nextToken)
                        {
                        case 2:
                            stream.TagLastToken((short)17408);
                            while (true)
                            {
                                nextToken = stream.GetNextToken();
                                switch (nextToken)
                                {
                                case 3:
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken((short)20480);
                                    continue;

                                case -1:
                                    goto label_18;

                                case 1:
                                    goto label_20;

                                default:
                                    goto label_19;
                                }
                            }
label_18:
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_19:
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
label_20:
                            flag4 = false;
                            ++index;
                            flag6 = false;
                            --num1;
                            flag1 = true;
                            break;

                        case 3:
                            flag3 = true;
                            stream.TagLastToken((short)16640);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            if (securityElementType != SecurityElementType.Regular)
                            {
                                throw new XmlSyntaxException(this._t.LineNo);
                            }
                            flag1 = true;
                            ++num1;
                            break;

                        case 6:
                            num2 = 1;
                            do
                            {
                                nextToken = stream.GetNextToken();
                                switch (nextToken)
                                {
                                case 0:
                                    ++num2;
                                    break;

                                case 1:
                                    --num2;
                                    break;

                                case 3:
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken((short)20480);
                                    break;
                                }
                            }while (num2 > 0);
                            flag4 = false;
                            flag6 = false;
                            flag1 = true;
                            break;

                        case 5:
                            nextToken = stream.GetNextToken();
                            if ((int)nextToken != 3)
                            {
                                throw new XmlSyntaxException(this._t.LineNo);
                            }
                            flag3 = true;
                            securityElementType = SecurityElementType.Format;
                            stream.TagLastToken((short)16640);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            num2   = 1;
                            ++num1;
                            flag1 = true;
                            break;

                        default:
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString"));
                        }

                    case 1:
                        if (!flag4)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket"));
                        }
                        flag4 = false;
                        continue;

                    case 2:
                        nextToken = stream.GetNextToken();
                        if ((int)nextToken != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        stream.TagLastToken((short)17408);
                        ++index;
                        --num1;
                        flag6 = false;
                        flag1 = true;
                        break;

                    case 3:
                        if (flag4)
                        {
                            if (securityElementType == SecurityElementType.Comment)
                            {
                                stream.ThrowAwayNextString();
                                stream.TagLastToken((short)20480);
                                break;
                            }
                            if (str == null)
                            {
                                str = stream.GetNextString();
                                break;
                            }
                            if (!flag5)
                            {
                                throw new XmlSyntaxException(this._t.LineNo);
                            }
                            stream.TagLastToken((short)16896);
                            index += SecurityDocument.EncodedStringSize(str) + SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                            str    = (string)null;
                            flag5  = false;
                            break;
                        }
                        if (flag6)
                        {
                            stream.TagLastToken((short)25344);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" ");
                            break;
                        }
                        stream.TagLastToken((short)17152);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        flag6  = true;
                        break;

                    case 4:
                        flag5 = true;
                        break;

                    case 5:
                        if (!flag4 || securityElementType != SecurityElementType.Format || num2 != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        nextToken = stream.GetNextToken();
                        if ((int)nextToken != 1)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        stream.TagLastToken((short)17408);
                        ++index;
                        --num1;
                        flag6 = false;
                        flag1 = true;
                        break;

                    default:
                        throw new XmlSyntaxException(this._t.LineNo);
                    }
                    if (flag1)
                    {
                        flag1 = false;
                        flag2 = false;
                        break;
                    }
                    flag2 = true;
                }
                if (flag2)
                {
                    ++index;
                    --num1;
                    flag6 = false;
                }
                else if ((int)nextToken == -1 && (num1 != 1 || !flag3))
                {
                    throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
            }while (num1 > 1);
        }
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            //
            // Iteratively collect stuff up until the next end-tag.
            // We've already seen the open-tag.
            //

            bool needToBreak         = false;
            bool needToPop           = false;
            bool createdNode         = false;
            bool intag               = false;
            int  stackDepth          = 1;
            SecurityElementType type = SecurityElementType.Regular;
            String strValue          = null;
            bool   sawEquals         = false;
            bool   sawText           = false;
            int    status            = 0;

            short i;

            do
            {
                for (i = stream.GetNextToken(); i != -1; i = stream.GetNextToken())
                {
                    switch (i & 0x00FF)
                    {
                    case Tokenizer.cstr:
                    {
                        if (intag)
                        {
                            if (type == SecurityElementType.Comment)
                            {
                                // Ignore data in comments but still get the data
                                // to keep the stream in the right place.
                                stream.ThrowAwayNextString();
                                stream.TagLastToken(c_wastedstringtag);
                            }
                            else
                            {
                                // We're in a regular tag, so we've found an attribute/value pair.

                                if (strValue == null)
                                {
                                    // Found attribute name, save it for later.

                                    strValue = stream.GetNextString();
                                }
                                else
                                {
                                    // Found attribute text, add the pair to the current element.

                                    if (!sawEquals)
                                    {
                                        throw new XmlSyntaxException(_t.LineNo);
                                    }

                                    stream.TagLastToken(c_attributetag);
                                    index += SecurityDocument.EncodedStringSize(strValue) +
                                             SecurityDocument.EncodedStringSize(stream.GetNextString()) +
                                             1;
                                    strValue  = null;
                                    sawEquals = false;
                                }
                            }
                        }
                        else
                        {
                            // We're not in a tag, so we've found text between tags.

                            if (sawText)
                            {
                                stream.TagLastToken(c_additionaltexttag);
                                index += SecurityDocument.EncodedStringSize(stream.GetNextString()) +
                                         SecurityDocument.EncodedStringSize(" ");
                            }
                            else
                            {
                                stream.TagLastToken(c_texttag);
                                index += SecurityDocument.EncodedStringSize(stream.GetNextString()) +
                                         1;
                                sawText = true;
                            }
                        }
                    }
                    break;

                    case Tokenizer.bra:
                        intag   = true;
                        sawText = false;
                        i       = stream.GetNextToken();

                        if (i == Tokenizer.slash)
                        {
                            stream.TagLastToken(c_childrentag);
                            while (true)
                            {
                                // spin; don't care what's in here
                                i = stream.GetNextToken();
                                if (i == Tokenizer.cstr)
                                {
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken(c_wastedstringtag);
                                }
                                else if (i == -1)
                                {
                                    throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (i != Tokenizer.ket)
                            {
                                throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                            }

                            intag = false;

                            // Found the end of this element
                            index++;

                            sawText = false;
                            stackDepth--;

                            needToBreak = true;
                        }
                        else if (i == Tokenizer.cstr)
                        {
                            // Found a child

                            createdNode = true;

                            stream.TagLastToken(c_elementtag);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) +
                                     1;

                            if (type != SecurityElementType.Regular)
                            {
                                throw new XmlSyntaxException(_t.LineNo);
                            }

                            needToBreak = true;
                            stackDepth++;
                        }
                        else if (i == Tokenizer.bang)
                        {
                            // Found a child that is a comment node.  Next up better be a cstr.

                            status = 1;

                            do
                            {
                                i = stream.GetNextToken();

                                switch (i)
                                {
                                case Tokenizer.bra:
                                    status++;
                                    break;

                                case Tokenizer.ket:
                                    status--;
                                    break;

                                case Tokenizer.cstr:
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken(c_wastedstringtag);
                                    break;

                                default:
                                    break;
                                }
                            } while (status > 0);

                            intag       = false;
                            sawText     = false;
                            needToBreak = true;
                        }
                        else if (i == Tokenizer.quest)
                        {
                            // Found a child that is a format node.  Next up better be a cstr.

                            i = stream.GetNextToken();

                            if (i != Tokenizer.cstr)
                            {
                                throw new XmlSyntaxException(_t.LineNo);
                            }

                            createdNode = true;

                            type = SecurityElementType.Format;

                            stream.TagLastToken(c_elementtag);
                            index += SecurityDocument.EncodedStringSize(stream.GetNextString()) +
                                     1;

                            status = 1;
                            stackDepth++;

                            needToBreak = true;
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString"));
                        }
                        break;

                    case Tokenizer.equals:
                        sawEquals = true;
                        break;

                    case Tokenizer.ket:
                        if (intag)
                        {
                            intag = false;
                            continue;
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket"));
                        }
                    // not reachable

                    case Tokenizer.slash:
                        i = stream.GetNextToken();

                        if (i == Tokenizer.ket)
                        {
                            // Found the end of this element
                            stream.TagLastToken(c_childrentag);
                            index++;
                            stackDepth--;
                            sawText = false;

                            needToBreak = true;
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                        }
                        break;

                    case Tokenizer.quest:
                        if (intag && type == SecurityElementType.Format && status == 1)
                        {
                            i = stream.GetNextToken();

                            if (i == Tokenizer.ket)
                            {
                                stream.TagLastToken(c_childrentag);
                                index++;
                                stackDepth--;
                                sawText = false;

                                needToBreak = true;
                            }
                            else
                            {
                                throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                            }
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo);
                        }
                        break;

                    case Tokenizer.dash:
                    default:
                        throw new XmlSyntaxException(_t.LineNo);
                    }

                    if (needToBreak)
                    {
                        needToBreak = false;
                        needToPop   = false;
                        break;
                    }
                    else
                    {
                        needToPop = true;
                    }
                }

                if (needToPop)
                {
                    index++;
                    stackDepth--;
                    sawText = false;
                }
                else if (i == -1 && (stackDepth != 1 || !createdNode))
                {
                    // This means that we still have items on the stack, but the end of our
                    // stream has been reached.

                    throw new XmlSyntaxException(_t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
            }while (stackDepth > 1);
        }
        private void ParseContents()
        {
            short i;

            TokenizerStream stream = new TokenizerStream();

            _t.GetTokens(stream, 2, false);
            stream.Reset();

            int gotoPosition = DetermineFormat(stream);

            stream.GoToPosition(gotoPosition);
            _t.GetTokens(stream, -1, false);
            stream.Reset();

            int neededIndex = 0;

            GetRequiredSizes(stream, ref neededIndex);

            _doc = new SecurityDocument(neededIndex);
            int position = 0;

            stream.Reset();

            for (i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken())
            {
                if ((i & c_flag) != c_flag)
                {
                    continue;
                }
                else
                {
                    switch ((short)(i & 0xFF00))
                    {
                    case c_elementtag:
                        _doc.AddToken(SecurityDocument.c_element, ref position);
                        _doc.AddString(stream.GetNextString(), ref position);
                        break;

                    case c_attributetag:
                        _doc.AddToken(SecurityDocument.c_attribute, ref position);
                        _doc.AddString(stream.GetNextString(), ref position);
                        _doc.AddString(stream.GetNextString(), ref position);
                        break;

                    case c_texttag:
                        _doc.AddToken(SecurityDocument.c_text, ref position);
                        _doc.AddString(stream.GetNextString(), ref position);
                        break;

                    case c_additionaltexttag:
                        _doc.AppendString(" ", ref position);
                        _doc.AppendString(stream.GetNextString(), ref position);
                        break;

                    case c_childrentag:
                        _doc.AddToken(SecurityDocument.c_children, ref position);
                        break;

                    case c_wastedstringtag:
                        stream.ThrowAwayNextString();
                        break;

                    default:
                        throw new XmlSyntaxException();
                    }
                }
            }
        }
        // Token: 0x06002BA9 RID: 11177 RVA: 0x000A3D34 File Offset: 0x000A1F34
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num   = 0;
                bool flag  = false;
                bool flag2 = false;
                Tokenizer.StringMaker maker = this._maker;
                maker._outStringBuilder = null;
                maker._outIndex         = 0;
                int num2;
                for (;;)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 >= this._inSize)
                            {
                                goto Block_3;
                            }
                            num2           = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                            this._inIndex += 2;
                            break;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_4;
                            }
                            byte[] inBytes = this._inBytes;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes[num3];
                            if ((num2 & 128) != 0)
                            {
                                switch ((num2 & 240) >> 4)
                                {
                                case 8:
                                case 9:
                                case 10:
                                case 11:
                                    goto IL_12D;

                                case 12:
                                case 13:
                                    num2 &= 31;
                                    num   = 2;
                                    break;

                                case 14:
                                    num2 &= 15;
                                    num   = 3;
                                    break;

                                case 15:
                                    goto IL_14B;
                                }
                                if (this._inIndex >= this._inSize)
                                {
                                    goto Block_7;
                                }
                                byte[] inBytes2 = this._inBytes;
                                num3          = this._inIndex;
                                this._inIndex = num3 + 1;
                                byte b = inBytes2[num3];
                                if ((b & 192) != 128)
                                {
                                    goto Block_8;
                                }
                                num2 = (num2 << 6 | (int)(b & 63));
                                if (num != 2)
                                {
                                    if (this._inIndex >= this._inSize)
                                    {
                                        goto Block_10;
                                    }
                                    byte[] inBytes3 = this._inBytes;
                                    num3          = this._inIndex;
                                    this._inIndex = num3 + 1;
                                    b             = inBytes3[num3];
                                    if ((b & 192) != 128)
                                    {
                                        goto Block_11;
                                    }
                                    num2 = (num2 << 6 | (int)(b & 63));
                                }
                            }
                            break;
                        }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_12;
                            }
                            byte[] inBytes4 = this._inBytes;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes4[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.CharArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_13;
                            }
                            char[] inChars = this._inChars;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inChars[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.String:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_14;
                            }
                            string inString = this._inString;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.NestedStrings:
                        {
                            int num3;
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string inNestedString = this._inNestedString;
                                    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    num2 = (int)inNestedString[num3];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_17;
                            }
                            string inString2 = this._inString;
                            num3          = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString2[num3];
                            if (num2 == 123)
                            {
                                for (int i = 0; i < this._searchStrings.Length; i++)
                                {
                                    if (string.Compare(this._searchStrings[i], 0, this._inString, this._inIndex - 1, this._searchStrings[i].Length, StringComparison.Ordinal) == 0)
                                    {
                                        this._inNestedString = this._replaceStrings[i];
                                        this._inNestedSize   = this._inNestedString.Length;
                                        this._inNestedIndex  = 1;
                                        num2           = (int)this._inNestedString[0];
                                        this._inIndex += this._searchStrings[i].Length - 1;
                                        break;
                                    }
                                }
                            }
                            break;
                        }

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 == -1)
                            {
                                goto Block_21;
                            }
                            break;
                        }
                    }
                    if (!flag)
                    {
                        if (num2 <= 34)
                        {
                            switch (num2)
                            {
                            case 9:
                            case 13:
                                continue;

                            case 10:
                                this.LineNo++;
                                continue;

                            case 11:
                            case 12:
                                break;

                            default:
                                switch (num2)
                                {
                                case 32:
                                    continue;

                                case 33:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_32;
                                    }
                                    break;

                                case 34:
                                    flag  = true;
                                    flag2 = true;
                                    continue;
                                }
                                break;
                            }
                        }
                        else if (num2 != 45)
                        {
                            if (num2 != 47)
                            {
                                switch (num2)
                                {
                                case 60:
                                    goto IL_48A;

                                case 61:
                                    goto IL_4C0;

                                case 62:
                                    goto IL_4A4;

                                case 63:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_31;
                                    }
                                    break;
                                }
                            }
                            else if (this._inProcessingTag != 0)
                            {
                                goto Block_30;
                            }
                        }
                        else if (this._inProcessingTag != 0)
                        {
                            goto Block_33;
                        }
                    }
                    else if (num2 <= 34)
                    {
                        switch (num2)
                        {
                        case 9:
                        case 13:
                            break;

                        case 10:
                            this.LineNo++;
                            if (!flag2)
                            {
                                goto Block_46;
                            }
                            goto IL_62F;

                        case 11:
                        case 12:
                            goto IL_62F;

                        default:
                            if (num2 != 32)
                            {
                                if (num2 != 34)
                                {
                                    goto IL_62F;
                                }
                                if (flag2)
                                {
                                    goto Block_44;
                                }
                                goto IL_62F;
                            }
                            break;
                        }
                        if (!flag2)
                        {
                            goto Block_45;
                        }
                    }
                    else
                    {
                        if (num2 != 47)
                        {
                            if (num2 != 60)
                            {
                                if (num2 - 61 > 1)
                                {
                                    goto IL_62F;
                                }
                            }
                            else
                            {
                                if (!flag2)
                                {
                                    goto Block_41;
                                }
                                goto IL_62F;
                            }
                        }
                        if (!flag2 && this._inProcessingTag != 0)
                        {
                            goto Block_43;
                        }
                    }
IL_62F:
                    flag = true;
                    if (maker._outIndex < 512)
                    {
                        char[] outChars = maker._outChars;
                        Tokenizer.StringMaker stringMaker = maker;
                        int num3 = stringMaker._outIndex;
                        stringMaker._outIndex = num3 + 1;
                        outChars[num3]        = (ushort)num2;
                    }
                    else
                    {
                        if (maker._outStringBuilder == null)
                        {
                            maker._outStringBuilder = new StringBuilder();
                        }
                        maker._outStringBuilder.Append(maker._outChars, 0, 512);
                        maker._outChars[0] = (char)num2;
                        maker._outIndex    = 1;
                    }
                }
IL_48A:
                this._inProcessingTag++;
                stream.AddToken(0);
                continue;
Block_3:
                stream.AddToken(-1);
                return;

IL_4A4:
                this._inProcessingTag--;
                stream.AddToken(1);
                if (endAfterKet)
                {
                    return;
                }
                continue;
IL_4C0:
                stream.AddToken(4);
                continue;
Block_30:
                stream.AddToken(2);
                continue;
Block_31:
                stream.AddToken(5);
                continue;
Block_32:
                stream.AddToken(6);
                continue;
Block_33:
                stream.AddToken(7);
                continue;
Block_41:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_43:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_44:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_45:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_46:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_4:
                stream.AddToken(-1);
                return;

IL_12D:
                throw new XmlSyntaxException(this.LineNo);
IL_14B:
                throw new XmlSyntaxException(this.LineNo);
Block_7:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_8:
                throw new XmlSyntaxException(this.LineNo);
Block_10:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_11:
                throw new XmlSyntaxException(this.LineNo);
Block_12:
                stream.AddToken(-1);
                return;

Block_13:
                stream.AddToken(-1);
                return;

Block_14:
                stream.AddToken(-1);
                return;

Block_17:
                stream.AddToken(-1);
                return;

Block_21:
                stream.AddToken(-1);
                return;
            }
        }
Beispiel #17
0
        internal void GetTokens( TokenizerStream stream, int maxNum, bool endAfterKet )
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int i = -1;
                byte ch;
                int cb = 0;
                bool inLiteral = false;
                bool inQuotedString = false;
            
                StringMaker m = _maker;
            
                m._outStringBuilder = null;
                m._outIndex = 0;
                        
            BEGINNING: 
            
                if (_inSavedCharacter != -1)
                {
                       i = _inSavedCharacter;
                       _inSavedCharacter = -1;
                }
                else switch (_inTokenSource)
                {
                case TokenSource.UnicodeByteArray:
                    if (_inIndex + 1 >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                     i = (int)((_inBytes[_inIndex+1]<<8) + _inBytes[_inIndex]);
                      _inIndex += 2;      
                    break;
                
                 case TokenSource.UTF8ByteArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inBytes[_inIndex++]);

                    // single byte -- case, early out as we're done already
                    if ((i & 0x80) == 0x00)
                        break;

                    // to decode the lead byte switch on the high nibble 
                    // shifted down so the switch gets dense integers
                    switch ((i & 0xf0) >>4)
                    {
                    case 0x8:   // 1000  (together these 4 make 10xxxxx)
                    case 0x9:   // 1001
                    case 0xa:   // 1010
                    case 0xb:   // 1011
                        // trail byte is an error
                        throw new XmlSyntaxException( LineNo );

                    case 0xc:   // 1100  (these two make 110xxxxx)
                    case 0xd:   // 1101
                        // two byte encoding (1 trail byte)
                        i &= 0x1f;
                        cb = 2;
                        break;

                    case 0xe:   // 1110 (this gets us 1110xxxx)
                        // three byte encoding (2 trail bytes)
                        i &= 0x0f;
                        cb = 3;
                        break;

                    case 0xf:   // 1111 (and finally 1111xxxx)
                        // 4 byte encoding is an error
                        throw new XmlSyntaxException( LineNo );
                    }

                    // at least one trail byte, fetch it
                    if (_inIndex >= _inSize)
                        throw new XmlSyntaxException (LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));

                    ch = _inBytes[_inIndex++];

                    // must be trail byte encoding
                    if ((ch & 0xc0) != 0x80)
                        throw new XmlSyntaxException( LineNo );

                    i = (i<<6) | (ch & 0x3f);

                    // done now if 2 byte encoding, otherwise go for 3
                    if (cb == 2)
                        break;

                    if (_inIndex >= _inSize)
                        throw new XmlSyntaxException (LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));

                    ch = _inBytes[_inIndex++];

                    // must be trail byte encoding
                    if ((ch & 0xc0) != 0x80)
                        throw new XmlSyntaxException( LineNo );

                    i = (i<<6) | (ch & 0x3f);
                    break;                
                
                case TokenSource.ASCIIByteArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inBytes[_inIndex++]);
                    break;

                case TokenSource.CharArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                     i = (int)(_inChars[_inIndex++]);
                    break;
                
                case TokenSource.String:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inString[_inIndex++]);
                    break;
                            
                case TokenSource.NestedStrings:
                    if (_inNestedSize != 0)
                    {
                        if (_inNestedIndex < _inNestedSize)
                        {
                            i = _inNestedString[_inNestedIndex++];
                            break;
                        }
                    
                        _inNestedSize = 0;
                    }
                
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inString[_inIndex++]);
                
                    if (i != '{')
                        break;
                                    
                    for (int istr=0; istr < _searchStrings.Length; istr++)
                    {
                        if (0==String.Compare(_searchStrings[istr], 0, _inString, _inIndex-1, _searchStrings[istr].Length, StringComparison.Ordinal))
                        {
                            _inNestedString = _replaceStrings[istr];
                            _inNestedSize = _inNestedString.Length;
                            _inNestedIndex = 1;
                            i = _inNestedString[0];
                            _inIndex += _searchStrings[istr].Length - 1;   
                            break;
                        }
                    }
                
                    break;
                    
                default:
                    i = _inTokenReader.Read();
                    if (i == -1) 
                    {
                        stream.AddToken( -1 );
                        return;
                    }
                    break;
                }

                if (!inLiteral)
                {
                    switch (i)
                    {
                    // skip whitespace
                    case intSpace:
                    case intTab:
                    case intCR:
                        goto BEGINNING;

                    // count linefeeds
                    case intLF:
                        LineNo++;
                        goto BEGINNING;
                                        
                    case intOpenBracket:
                        _inProcessingTag++;
                        stream.AddToken( bra );
                        continue;
                    
                    case intCloseBracket:
                        _inProcessingTag--;
                        stream.AddToken( ket );
                        if (endAfterKet)
                            return;
                        continue;
                    
                    case intEquals:
                        stream.AddToken( equals );
                        continue;
                    
                    case intSlash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( slash );
                            continue;
                        }
                        break;

                    case intQuest:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( quest );
                            continue;
                        } 
                        break;

                    case intBang:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( bang );
                            continue;
                        } 
                        break;

                    case intDash:
                        if (_inProcessingTag != 0) 
                        {
                            stream.AddToken( dash );
                            continue;
                        }
                        break;

                    case intQuote:
                        inLiteral = true;
                        inQuotedString = true;
                        goto BEGINNING;
                    }
                }
                else
                   {
                    switch (i)
                    {
                    case intOpenBracket:
                        if (!inQuotedString)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                        
                    case intCloseBracket:
                    case intEquals:
                    case intSlash:
                        if (!inQuotedString && _inProcessingTag != 0)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                    
                    case intQuote:
                        if (inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                    
                    case intTab:
                    case intCR:
                    case intSpace:
                        if (!inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;

                    // count linefeeds
                    case intLF:
                        LineNo++;

                        if (!inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;                        
                    }
                }

                inLiteral = true;
                                       
                // add character  to the string
                if (m._outIndex < StringMaker.outMaxSize) 
                {
                    // easy case
                    m._outChars[m._outIndex++] = (char)i;
                } 
                else
                {
                    if (m._outStringBuilder == null) 
                    {
                       // OK, first check if we have to init the StringBuilder
                        m._outStringBuilder = new StringBuilder();
                    }
                
                    // OK, copy from _outChars to _outStringBuilder
                    m._outStringBuilder.Append(m._outChars, 0, StringMaker.outMaxSize);
                
                    // reset _outChars pointer
                    m._outChars[0] = (char)i;
                    m._outIndex = 1;
                }
                        
                goto BEGINNING;
            }
        }
        private void ParseContents()
        {
            TokenizerStream stream = new TokenizerStream();

            this._t.GetTokens(stream, 2, false);
            stream.Reset();
            int position = this.DetermineFormat(stream);

            stream.GoToPosition(position);
            this._t.GetTokens(stream, -1, false);
            stream.Reset();
            int index = 0;

            this.GetRequiredSizes(stream, ref index);
            this._doc = new SecurityDocument(index);
            int num4 = 0;

            stream.Reset();
            for (short i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken())
            {
                if ((i & 0x4000) == 0x4000)
                {
                    switch (((short)(i & 0xff00)))
                    {
                    case 0x4400:
                    {
                        this._doc.AddToken(4, ref num4);
                        continue;
                    }

                    case 0x5000:
                    {
                        stream.ThrowAwayNextString();
                        continue;
                    }

                    case 0x6300:
                    {
                        this._doc.AppendString(" ", ref num4);
                        this._doc.AppendString(stream.GetNextString(), ref num4);
                        continue;
                    }

                    case 0x4100:
                    {
                        this._doc.AddToken(1, ref num4);
                        this._doc.AddString(stream.GetNextString(), ref num4);
                        continue;
                    }

                    case 0x4200:
                    {
                        this._doc.AddToken(2, ref num4);
                        this._doc.AddString(stream.GetNextString(), ref num4);
                        this._doc.AddString(stream.GetNextString(), ref num4);
                        continue;
                    }

                    case 0x4300:
                    {
                        this._doc.AddToken(3, ref num4);
                        this._doc.AddString(stream.GetNextString(), ref num4);
                        continue;
                    }
                    }
                    throw new XmlSyntaxException();
                }
            }
        }
Beispiel #19
0
        private void ParseContents() 
        { 
            short i;
 
            TokenizerStream stream = new TokenizerStream();

            _t.GetTokens( stream, 2, false );
            stream.Reset(); 

            int gotoPosition = DetermineFormat( stream ); 
 
            stream.GoToPosition( gotoPosition );
            _t.GetTokens( stream, -1, false ); 
            stream.Reset();

            int neededIndex = 0;
 
            GetRequiredSizes( stream, ref neededIndex );
 
            _doc = new SecurityDocument( neededIndex ); 
            int position = 0;
 
            stream.Reset();

            for (i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken())
            { 
                if ((i & c_flag) != c_flag)
                    continue; 
                else 
                {
                    switch((short)(i & 0xFF00)) 
                    {
                    case c_elementtag:
                        _doc.AddToken( SecurityDocument.c_element, ref position );
                        _doc.AddString( stream.GetNextString(), ref position ); 
                        break;
 
                    case c_attributetag: 
                        _doc.AddToken( SecurityDocument.c_attribute, ref position );
                        _doc.AddString( stream.GetNextString(), ref position ); 
                        _doc.AddString( stream.GetNextString(), ref position );
                        break;

                    case c_texttag: 
                        _doc.AddToken( SecurityDocument.c_text, ref position );
                        _doc.AddString( stream.GetNextString(), ref position ); 
                        break; 

                    case c_additionaltexttag: 
                        _doc.AppendString( " ", ref position );
                        _doc.AppendString( stream.GetNextString(), ref position );
                        break;
 
                    case c_childrentag:
                        _doc.AddToken( SecurityDocument.c_children, ref position ); 
                        break; 

                    case c_wastedstringtag: 
                        stream.ThrowAwayNextString();
                        break;

                    default: 
                        throw new XmlSyntaxException();
                    } 
                } 
            }
        } 
Beispiel #20
0
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while ((maxNum == -1) || (stream.GetTokenCount() < maxNum))
            {
                int         num   = -1;
                int         num3  = 0;
                bool        flag  = false;
                bool        flag2 = false;
                StringMaker maker = this._maker;
                maker._outStringBuilder = null;
                maker._outIndex         = 0;
Label_0026:
                if (this._inSavedCharacter != -1)
                {
                    num = this._inSavedCharacter;
                    this._inSavedCharacter = -1;
                }
                else
                {
                    switch (this._inTokenSource)
                    {
                    case TokenSource.UnicodeByteArray:
                        if ((this._inIndex + 1) < this._inSize)
                        {
                            break;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.UTF8ByteArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_00CF;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.ASCIIByteArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_023C;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.CharArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_0272;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.String:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_02A8;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.NestedStrings:
                        if (this._inNestedSize == 0)
                        {
                            goto Label_030D;
                        }
                        if (this._inNestedIndex >= this._inNestedSize)
                        {
                            goto Label_0306;
                        }
                        num = this._inNestedString[this._inNestedIndex++];
                        goto Label_0402;

                    default:
                        num = this._inTokenReader.Read();
                        if (num == -1)
                        {
                            stream.AddToken(-1);
                            return;
                        }
                        goto Label_0402;
                    }
                    num            = (this._inBytes[this._inIndex + 1] << 8) + this._inBytes[this._inIndex];
                    this._inIndex += 2;
                }
                goto Label_0402;
Label_00CF:
                num = this._inBytes[this._inIndex++];
                if ((num & 0x80) != 0)
                {
                    switch (((num & 240) >> 4))
                    {
                    case 8:
                    case 9:
                    case 10:
                    case 11:
                        throw new XmlSyntaxException(this.LineNo);

                    case 12:
                    case 13:
                        num &= 0x1f;
                        num3 = 2;
                        break;

                    case 14:
                        num &= 15;
                        num3 = 3;
                        break;

                    case 15:
                        throw new XmlSyntaxException(this.LineNo);
                    }
                    if (this._inIndex >= this._inSize)
                    {
                        throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                    }
                    byte num2 = this._inBytes[this._inIndex++];
                    if ((num2 & 0xc0) != 0x80)
                    {
                        throw new XmlSyntaxException(this.LineNo);
                    }
                    num = (num << 6) | (num2 & 0x3f);
                    if (num3 != 2)
                    {
                        if (this._inIndex >= this._inSize)
                        {
                            throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }
                        num2 = this._inBytes[this._inIndex++];
                        if ((num2 & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(this.LineNo);
                        }
                        num = (num << 6) | (num2 & 0x3f);
                    }
                }
                goto Label_0402;
Label_023C:
                num = this._inBytes[this._inIndex++];
                goto Label_0402;
Label_0272:
                num = this._inChars[this._inIndex++];
                goto Label_0402;
Label_02A8:
                num = this._inString[this._inIndex++];
                goto Label_0402;
Label_0306:
                this._inNestedSize = 0;
Label_030D:
                if (this._inIndex >= this._inSize)
                {
                    stream.AddToken(-1);
                    return;
                }
                num = this._inString[this._inIndex++];
                if (num == 0x7b)
                {
                    for (int i = 0; i < this._searchStrings.Length; i++)
                    {
                        if (string.Compare(this._searchStrings[i], 0, this._inString, this._inIndex - 1, this._searchStrings[i].Length, StringComparison.Ordinal) == 0)
                        {
                            this._inNestedString = this._replaceStrings[i];
                            this._inNestedSize   = this._inNestedString.Length;
                            this._inNestedIndex  = 1;
                            num            = this._inNestedString[0];
                            this._inIndex += this._searchStrings[i].Length - 1;
                            break;
                        }
                    }
                }
Label_0402:
                if (!flag)
                {
                    switch (num)
                    {
                    case 9:
                    case 13:
                    case 0x20:
                        goto Label_0026;

                    case 10:
                        this.LineNo++;
                        goto Label_0026;

                    case 0x21:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(6);
                        continue;
                    }

                    case 0x22:
                        flag  = true;
                        flag2 = true;
                        goto Label_0026;

                    case 0x2d:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(7);
                        continue;
                    }

                    case 0x2f:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(2);
                        continue;
                    }

                    case 60:
                    {
                        this._inProcessingTag++;
                        stream.AddToken(0);
                        continue;
                    }

                    case 0x3d:
                    {
                        stream.AddToken(4);
                        continue;
                    }

                    case 0x3e:
                        this._inProcessingTag--;
                        stream.AddToken(1);
                        if (!endAfterKet)
                        {
                            continue;
                        }
                        return;

                    case 0x3f:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(5);
                        continue;
                    }
                    }
                }
                else
                {
                    switch (num)
                    {
                    case 60:
                    {
                        if (flag2)
                        {
                            break;
                        }
                        this._inSavedCharacter = num;
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 0x3d:
                    case 0x3e:
                    case 0x2f:
                    {
                        if (flag2 || (this._inProcessingTag == 0))
                        {
                            break;
                        }
                        this._inSavedCharacter = num;
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 9:
                    case 13:
                    case 0x20:
                    {
                        if (flag2)
                        {
                            break;
                        }
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 10:
                        goto Label_0629;

                    case 0x22:
                    {
                        if (!flag2)
                        {
                            break;
                        }
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }
                    }
                }
                goto Label_0650;
Label_0629:
                this.LineNo++;
                if (!flag2)
                {
                    stream.AddToken(3);
                    stream.AddString(this.GetStringToken());
                    continue;
                }
Label_0650:
                flag = true;
                if (maker._outIndex < 0x200)
                {
                    maker._outChars[maker._outIndex++] = (char)num;
                }
                else
                {
                    if (maker._outStringBuilder == null)
                    {
                        maker._outStringBuilder = new StringBuilder();
                    }
                    maker._outStringBuilder.Append(maker._outChars, 0, 0x200);
                    maker._outChars[0] = (char)num;
                    maker._outIndex    = 1;
                }
                goto Label_0026;
            }
        }
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  i = -1;
                byte ch;
                int  cb             = 0;
                bool inLiteral      = false;
                bool inQuotedString = false;

                StringMaker m = _maker;

                m._outStringBuilder = null;
                m._outIndex         = 0;

BEGINNING:

                if (_inSavedCharacter != -1)
                {
                    i = _inSavedCharacter;
                    _inSavedCharacter = -1;
                }
                else
                {
                    switch (_inTokenSource)
                    {
                    case TokenSource.UnicodeByteArray:
                        if (_inIndex + 1 >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i         = (int)((_inBytes[_inIndex + 1] << 8) + _inBytes[_inIndex]);
                        _inIndex += 2;
                        break;

                    case TokenSource.UTF8ByteArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inBytes[_inIndex++]);

                        // single byte -- case, early out as we're done already
                        if ((i & 0x80) == 0x00)
                        {
                            break;
                        }

                        // to decode the lead byte switch on the high nibble
                        // shifted down so the switch gets dense integers
                        switch ((i & 0xf0) >> 4)
                        {
                        case 0x8: // 1000  (together these 4 make 10xxxxx)
                        case 0x9: // 1001
                        case 0xa: // 1010
                        case 0xb: // 1011
                            // trail byte is an error
                            throw new XmlSyntaxException(LineNo);

                        case 0xc: // 1100  (these two make 110xxxxx)
                        case 0xd: // 1101
                            // two byte encoding (1 trail byte)
                            i &= 0x1f;
                            cb = 2;
                            break;

                        case 0xe: // 1110 (this gets us 1110xxxx)
                            // three byte encoding (2 trail bytes)
                            i &= 0x0f;
                            cb = 3;
                            break;

                        case 0xf: // 1111 (and finally 1111xxxx)
                            // 4 byte encoding is an error
                            throw new XmlSyntaxException(LineNo);
                        }

                        // at least one trail byte, fetch it
                        if (_inIndex >= _inSize)
                        {
                            throw new XmlSyntaxException(LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }

                        ch = _inBytes[_inIndex++];

                        // must be trail byte encoding
                        if ((ch & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(LineNo);
                        }

                        i = (i << 6) | (ch & 0x3f);

                        // done now if 2 byte encoding, otherwise go for 3
                        if (cb == 2)
                        {
                            break;
                        }

                        if (_inIndex >= _inSize)
                        {
                            throw new XmlSyntaxException(LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }

                        ch = _inBytes[_inIndex++];

                        // must be trail byte encoding
                        if ((ch & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(LineNo);
                        }

                        i = (i << 6) | (ch & 0x3f);
                        break;

                    case TokenSource.ASCIIByteArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inBytes[_inIndex++]);
                        break;

                    case TokenSource.CharArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inChars[_inIndex++]);
                        break;

                    case TokenSource.String:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inString[_inIndex++]);
                        break;

                    case TokenSource.NestedStrings:
                        if (_inNestedSize != 0)
                        {
                            if (_inNestedIndex < _inNestedSize)
                            {
                                i = _inNestedString[_inNestedIndex++];
                                break;
                            }

                            _inNestedSize = 0;
                        }

                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inString[_inIndex++]);

                        if (i != '{')
                        {
                            break;
                        }

                        for (int istr = 0; istr < _searchStrings.Length; istr++)
                        {
                            if (0 == String.Compare(_searchStrings[istr], 0, _inString, _inIndex - 1, _searchStrings[istr].Length, StringComparison.Ordinal))
                            {
                                _inNestedString = _replaceStrings[istr];
                                _inNestedSize   = _inNestedString.Length;
                                _inNestedIndex  = 1;
                                i         = _inNestedString[0];
                                _inIndex += _searchStrings[istr].Length - 1;
                                break;
                            }
                        }

                        break;

                    default:
                        i = _inTokenReader.Read();
                        if (i == -1)
                        {
                            stream.AddToken(-1);
                            return;
                        }
                        break;
                    }
                }

                if (!inLiteral)
                {
                    switch (i)
                    {
                    // skip whitespace
                    case intSpace:
                    case intTab:
                    case intCR:
                        goto BEGINNING;

                    // count linefeeds
                    case intLF:
                        LineNo++;
                        goto BEGINNING;

                    case intOpenBracket:
                        _inProcessingTag++;
                        stream.AddToken(bra);
                        continue;

                    case intCloseBracket:
                        _inProcessingTag--;
                        stream.AddToken(ket);
                        if (endAfterKet)
                        {
                            return;
                        }
                        continue;

                    case intEquals:
                        stream.AddToken(equals);
                        continue;

                    case intSlash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(slash);
                            continue;
                        }
                        break;

                    case intQuest:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(quest);
                            continue;
                        }
                        break;

                    case intBang:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(bang);
                            continue;
                        }
                        break;

                    case intDash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(dash);
                            continue;
                        }
                        break;

                    case intQuote:
                        inLiteral      = true;
                        inQuotedString = true;
                        goto BEGINNING;
                    }
                }
                else
                {
                    switch (i)
                    {
                    case intOpenBracket:
                        if (!inQuotedString)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intCloseBracket:
                    case intEquals:
                    case intSlash:
                        if (!inQuotedString && _inProcessingTag != 0)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intQuote:
                        if (inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intTab:
                    case intCR:
                    case intSpace:
                        if (!inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    // count linefeeds
                    case intLF:
                        LineNo++;

                        if (!inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;
                    }
                }

                inLiteral = true;

                // add character  to the string
                if (m._outIndex < StringMaker.outMaxSize)
                {
                    // easy case
                    m._outChars[m._outIndex++] = (char)i;
                }
                else
                {
                    if (m._outStringBuilder == null)
                    {
                        // OK, first check if we have to init the StringBuilder
                        m._outStringBuilder = new StringBuilder();
                    }

                    // OK, copy from _outChars to _outStringBuilder
                    m._outStringBuilder.Append(m._outChars, 0, StringMaker.outMaxSize);

                    // reset _outChars pointer
                    m._outChars[0] = (char)i;
                    m._outIndex    = 1;
                }

                goto BEGINNING;
            }
        }
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            bool flag = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            int num = 1;
            SecurityElementType regular = SecurityElementType.Regular;
            string nextString = null;
            bool flag5 = false;
            bool flag6 = false;
            int num2 = 0;
            do
            {
                short nextToken = stream.GetNextToken();
                while (nextToken != -1)
                {
                    switch ((nextToken & 0xff))
                    {
                        case 0:
                            flag4 = true;
                            flag6 = false;
                            nextToken = stream.GetNextToken();
                            if (nextToken != 2)
                            {
                                goto Label_01BD;
                            }
                            stream.TagLastToken(0x4400);
                            while (true)
                            {
                                nextToken = stream.GetNextToken();
                                if (nextToken != 3)
                                {
                                    break;
                                }
                                stream.ThrowAwayNextString();
                                stream.TagLastToken(0x5000);
                            }
                            if (nextToken == -1)
                            {
                                throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                            }
                            if (nextToken != 1)
                            {
                                throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                            }
                            flag4 = false;
                            index++;
                            flag6 = false;
                            num--;
                            flag = true;
                            goto Label_03BD;

                        case 1:
                            if (!flag4)
                            {
                                throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket"));
                            }
                            flag4 = false;
                            goto Label_03C8;

                        case 2:
                            nextToken = stream.GetNextToken();
                            if (nextToken != 1)
                            {
                                throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                            }
                            stream.TagLastToken(0x4400);
                            index++;
                            num--;
                            flag6 = false;
                            flag = true;
                            goto Label_03BD;

                        case 3:
                            if (!flag4)
                            {
                                goto Label_00D1;
                            }
                            if (regular != SecurityElementType.Comment)
                            {
                                break;
                            }
                            stream.ThrowAwayNextString();
                            stream.TagLastToken(0x5000);
                            goto Label_03BD;

                        case 4:
                            flag5 = true;
                            goto Label_03BD;

                        case 5:
                            if ((!flag4 || (regular != SecurityElementType.Format)) || (num2 != 1))
                            {
                                throw new XmlSyntaxException(this._t.LineNo);
                            }
                            nextToken = stream.GetNextToken();
                            if (nextToken != 1)
                            {
                                throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket"));
                            }
                            stream.TagLastToken(0x4400);
                            index++;
                            num--;
                            flag6 = false;
                            flag = true;
                            goto Label_03BD;

                        default:
                            throw new XmlSyntaxException(this._t.LineNo);
                    }
                    if (nextString == null)
                    {
                        nextString = stream.GetNextString();
                    }
                    else
                    {
                        if (!flag5)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        stream.TagLastToken(0x4200);
                        index += (SecurityDocument.EncodedStringSize(nextString) + SecurityDocument.EncodedStringSize(stream.GetNextString())) + 1;
                        nextString = null;
                        flag5 = false;
                    }
                    goto Label_03BD;
                Label_00D1:
                    if (flag6)
                    {
                        stream.TagLastToken(0x6300);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" ");
                    }
                    else
                    {
                        stream.TagLastToken(0x4300);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        flag6 = true;
                    }
                    goto Label_03BD;
                Label_01BD:
                    if (nextToken == 3)
                    {
                        flag3 = true;
                        stream.TagLastToken(0x4100);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        if (regular != SecurityElementType.Regular)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        flag = true;
                        num++;
                    }
                    else if (nextToken == 6)
                    {
                        num2 = 1;
                        do
                        {
                            nextToken = stream.GetNextToken();
                            switch (nextToken)
                            {
                                case 0:
                                    num2++;
                                    break;

                                case 1:
                                    num2--;
                                    break;

                                case 3:
                                    stream.ThrowAwayNextString();
                                    stream.TagLastToken(0x5000);
                                    break;
                            }
                        }
                        while (num2 > 0);
                        flag4 = false;
                        flag6 = false;
                        flag = true;
                    }
                    else
                    {
                        if (nextToken != 5)
                        {
                            throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString"));
                        }
                        nextToken = stream.GetNextToken();
                        if (nextToken != 3)
                        {
                            throw new XmlSyntaxException(this._t.LineNo);
                        }
                        flag3 = true;
                        regular = SecurityElementType.Format;
                        stream.TagLastToken(0x4100);
                        index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1;
                        num2 = 1;
                        num++;
                        flag = true;
                    }
                Label_03BD:
                    if (flag)
                    {
                        flag = false;
                        flag2 = false;
                        break;
                    }
                    flag2 = true;
                Label_03C8:
                    nextToken = stream.GetNextToken();
                }
                if (flag2)
                {
                    index++;
                    num--;
                    flag6 = false;
                }
                else if ((nextToken == -1) && ((num != 1) || !flag3))
                {
                    throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                }
            }
            while (num > 1);
        }