GetNextToken() private method

private GetNextToken ( ) : short
return short
        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;
        }
Beispiel #5
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 #6
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;
        }
        // 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"));
        }
        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 #9
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 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);
        }