Beispiel #1
0
        private void ParseContents(SecurityElement e, bool restarted)
        {
            //
            // Iteratively collect stuff up until the next end-tag.
            // We've already seen the open-tag.
            //

            SecurityElementType lastType = SecurityElementType.Regular;

            ParserStack      stack      = new ParserStack();
            ParserStackFrame firstFrame = new ParserStackFrame();

            firstFrame.element = e;
            firstFrame.intag   = false;
            stack.Push(firstFrame);

            bool needToBreak = false;
            bool needToPop   = false;

            int i;

            do
            {
                ParserStackFrame locFrame = stack.Peek();

                for (i = _t.NextTokenType(); i != -1; i = _t.NextTokenType())
                {
                    switch (i)
                    {
                    case Tokenizer.cstr:
                    {
                        if (locFrame.intag)
                        {
                            if (locFrame.type == SecurityElementType.Comment)
                            {
                                String appendString;

                                if (locFrame.sawEquals)
                                {
                                    appendString       = "=\"" + _t.GetStringToken() + "\"";
                                    locFrame.sawEquals = false;
                                }
                                else
                                {
                                    appendString = " " + _t.GetStringToken();
                                }

                                // Always set this directly since comments are not subjected
                                // to the same restraints as other element types.  The strings
                                // are all escaped so this shouldn't be a problem.

                                locFrame.element.Tag = locFrame.element.Tag + appendString;
                            }
                            else
                            {
                                // We're in a regular tag, so we've found an attribute/value pair.

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

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

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

                                    locFrame.element.AddAttribute(locFrame.strValue, _t.GetStringToken());

                                    locFrame.strValue = null;
                                }
                            }
                        }
                        else
                        {
                            // We're not in a tag, so we've found text between tags.

                            if (locFrame.element.Text == null)
                            {
                                locFrame.element.Text = "";
                            }

                            StringBuilder sb = new StringBuilder(locFrame.element.Text);

                            //
                            // Separate tokens with single spaces, collapsing whitespace
                            //
                            if (!locFrame.element.Text.Equals(""))
                            {
                                sb.Append(" ");
                            }

                            sb.Append(_t.GetStringToken());
                            locFrame.element.Text = sb.ToString();
                        }
                    }
                    break;

                    case Tokenizer.bra:
                        locFrame.intag = true;
                        i = _t.NextTokenType();

                        if (i == Tokenizer.slash)
                        {
                            while (true)
                            {
                                // spin; don't care what's in here
                                i = _t.NextTokenType();
                                if (i == Tokenizer.cstr)
                                {
                                    continue;
                                }
                                else if (i == -1)
                                {
                                    throw new Exception("");
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (i != Tokenizer.ket)
                            {
                                throw new Exception("");
                            }

                            locFrame.intag = false;

                            // Found the end of this element
                            lastType = stack.Peek().type;
                            stack.Pop();

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

                            ParserStackFrame newFrame = new ParserStackFrame();

                            newFrame.element = new SecurityElement(_t.GetStringToken());

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

                            locFrame.element.AddChild(newFrame.element);

                            stack.Push(newFrame);

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

                            ParserStackFrame newFrame = new ParserStackFrame();

                            newFrame.status = 1;

                            do
                            {
                                i = _t.NextTokenType();

                                if (newFrame.status < 3)
                                {
                                    if (i != Tokenizer.dash)
                                    {
                                        throw new XmlSyntaxException(_t.LineNo);
                                    }
                                    else
                                    {
                                        newFrame.status++;
                                    }
                                }
                                else
                                {
                                    if (i != Tokenizer.cstr)
                                    {
                                        throw new XmlSyntaxException(_t.LineNo);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }while (true);


                            newFrame.element = new SecurityElement(_t.GetStringToken());

                            newFrame.type = SecurityElementType.Comment;

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

                            locFrame.element.AddChild(newFrame.element);

                            stack.Push(newFrame);

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

                            i = _t.NextTokenType();

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

                            ParserStackFrame newFrame = new ParserStackFrame();

                            newFrame.element = new SecurityElement(_t.GetStringToken());

                            newFrame.type = SecurityElementType.Format;

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

                            locFrame.element.AddChild(newFrame.element);

                            newFrame.status = 1;

                            stack.Push(newFrame);

                            needToBreak = true;
                        }
                        else
                        {
                            throw new Exception("");
                        }
                        break;

                    case Tokenizer.equals:
                        locFrame.sawEquals = true;
                        break;

                    case Tokenizer.ket:
                        if (locFrame.intag)
                        {
                            locFrame.intag = false;
                            continue;
                        }
                        else
                        {
                            throw new Exception("");
                        }
                    // not reachable

                    case Tokenizer.slash:
                        locFrame.element.Text = null;

                        i = _t.NextTokenType();

                        if (i == Tokenizer.ket)
                        {
                            // Found the end of this element
                            lastType = stack.Peek().type;
                            stack.Pop();

                            needToBreak = true;
                        }
                        else
                        {
                            throw new Exception("");
                        }
                        break;

                    case Tokenizer.quest:
                        if (locFrame.intag && locFrame.type == SecurityElementType.Format && locFrame.status == 1)
                        {
                            i = _t.NextTokenType();

                            if (i == Tokenizer.ket)
                            {
                                lastType = stack.Peek().type;
                                stack.Pop();

                                needToBreak = true;
                            }
                            else
                            {
                                throw new Exception("");
                            }
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo);
                        }
                        break;

                    case Tokenizer.dash:
                        if (locFrame.intag && (locFrame.status > 0 && locFrame.status < 5) && locFrame.type == SecurityElementType.Comment)
                        {
                            locFrame.status++;

                            if (locFrame.status == 5)
                            {
                                i = _t.NextTokenType();

                                if (i == Tokenizer.ket)
                                {
                                    lastType = stack.Peek().type;
                                    stack.Pop();

                                    needToBreak = true;
                                }
                                else
                                {
                                    throw new Exception("");
                                }
                            }
                        }
                        else
                        {
                            throw new XmlSyntaxException(_t.LineNo);
                        }
                        break;

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

                    if (needToBreak)
                    {
                        needToBreak = false;
                        needToPop   = false;
                        break;
                    }
                    else
                    {
                        needToPop = true;
                    }
                }
                if (needToPop)
                {
                    lastType = stack.Peek().type;
                    stack.Pop();
                }
                else if (i == -1 && stack.GetCount() != 1)
                {
                    // This means that we still have items on the stack, but the end of our
                    // stream has been reached.

                    throw new Exception("");
                }
            }while (stack.GetCount() > 1);

            SecurityElement topElement = this.GetTopElement();

            if (lastType == SecurityElementType.Format)
            {
                if (restarted)
                {
                    throw new XmlSyntaxException(_t.LineNo);
                }

                String format = topElement.Attribute("encoding");

                if (format != null)
                {
                    _t.ChangeFormat(System.Text.Encoding.GetEncoding(format));
                }

                _ecurr = new SecurityElement("junk");
                ParseContents(_ecurr, true);
            }
        }
Beispiel #2
0
        private void GetRequiredSizes(TokenizerStream stream, ref int index)
        {
            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("XMLSyntax_UnexpectedEndOfFile");
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (i != Tokenizer.ket)
                            {
                                throw new XmlSyntaxException("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("XMLSyntax_ExpectedSlashOrString");
                        }
                        break;

                    case Tokenizer.equals:
                        sawEquals = true;
                        break;

                    case Tokenizer.ket:
                        if (intag)
                        {
                            intag = false;
                            continue;
                        }
                        else
                        {
                            throw new XmlSyntaxException("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("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("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("XMLSyntax_UnexpectedEndOfFile");
                }
            }while (stackDepth > 1);
        }
        // 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 #5
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);
        }
        // Token: 0x06001BF6 RID: 7158 RVA: 0x00060194 File Offset: 0x0005E394
        private void ToString(string indent, object obj, SecurityElement.ToStringHelperFunc func)
        {
            func(obj, "<");
            SecurityElementType type = this.m_type;

            if (type != SecurityElementType.Format)
            {
                if (type == SecurityElementType.Comment)
                {
                    func(obj, "!");
                }
            }
            else
            {
                func(obj, "?");
            }
            func(obj, this.m_strTag);
            if (this.m_lAttributes != null && this.m_lAttributes.Count > 0)
            {
                func(obj, " ");
                int count = this.m_lAttributes.Count;
                for (int i = 0; i < count; i += 2)
                {
                    string str  = (string)this.m_lAttributes[i];
                    string str2 = (string)this.m_lAttributes[i + 1];
                    func(obj, str);
                    func(obj, "=\"");
                    func(obj, str2);
                    func(obj, "\"");
                    if (i != this.m_lAttributes.Count - 2)
                    {
                        if (this.m_type == SecurityElementType.Regular)
                        {
                            func(obj, Environment.NewLine);
                        }
                        else
                        {
                            func(obj, " ");
                        }
                    }
                }
            }
            if (this.m_strText == null && (this.m_lChildren == null || this.m_lChildren.Count == 0))
            {
                type = this.m_type;
                if (type != SecurityElementType.Format)
                {
                    if (type == SecurityElementType.Comment)
                    {
                        func(obj, ">");
                    }
                    else
                    {
                        func(obj, "/>");
                    }
                }
                else
                {
                    func(obj, " ?>");
                }
                func(obj, Environment.NewLine);
                return;
            }
            func(obj, ">");
            func(obj, this.m_strText);
            if (this.m_lChildren != null)
            {
                this.ConvertSecurityElementFactories();
                func(obj, Environment.NewLine);
                for (int j = 0; j < this.m_lChildren.Count; j++)
                {
                    ((SecurityElement)this.m_lChildren[j]).ToString("", obj, func);
                }
            }
            func(obj, "</");
            func(obj, this.m_strTag);
            func(obj, ">");
            func(obj, Environment.NewLine);
        }