Example #1
0
            public T peek()
            {
                if (_Stack.Count == 0)
                {
                    throw new EmptyStackException();
                }

                return(_Stack.Peek());
            }
Example #2
0
 public T peek()
 {
     return(_Stack.Peek());
 }
Example #3
0
        // Token: 0x060004E9 RID: 1257 RVA: 0x0001902C File Offset: 0x0001722C
        public static global::VRGIN.Helpers.JSONNode Parse(string aJSON)
        {
            global::System.Collections.Generic.Stack <global::VRGIN.Helpers.JSONNode> stack = new global::System.Collections.Generic.Stack <global::VRGIN.Helpers.JSONNode>();
            global::VRGIN.Helpers.JSONNode jsonnode = null;
            int    i     = 0;
            string text  = "";
            string text2 = "";
            bool   flag  = false;
            bool   flag2 = false;

            while (i < aJSON.Length)
            {
                char c  = aJSON.get_Chars(i);
                char c2 = c;
                if (c2 <= ',')
                {
                    if (c2 <= ' ')
                    {
                        switch (c2)
                        {
                        case '\t':
                            break;

                        case '\n':
                        case '\r':
                            goto IL_473;

                        case '\v':
                        case '\f':
                            goto IL_45A;

                        default:
                            if (c2 != ' ')
                            {
                                goto IL_45A;
                            }
                            break;
                        }
                        bool flag3 = flag;
                        if (flag3)
                        {
                            text += aJSON.get_Chars(i).ToString();
                        }
                    }
                    else if (c2 != '"')
                    {
                        if (c2 != ',')
                        {
                            goto IL_45A;
                        }
                        bool flag4 = flag;
                        if (flag4)
                        {
                            text += aJSON.get_Chars(i).ToString();
                        }
                        else
                        {
                            bool flag5 = text != "";
                            if (flag5)
                            {
                                global::VRGIN.Helpers.JSONNode.AddElement(jsonnode, text, text2, flag2);
                            }
                            text2 = "";
                            text  = "";
                            flag2 = false;
                        }
                    }
                    else
                    {
                        flag  = !flag;
                        flag2 = (flag || flag2);
                    }
                }
                else
                {
                    if (c2 <= ']')
                    {
                        if (c2 != ':')
                        {
                            switch (c2)
                            {
                            case '[':
                            {
                                bool flag6 = flag;
                                if (flag6)
                                {
                                    text += aJSON.get_Chars(i).ToString();
                                    goto IL_473;
                                }
                                stack.Push(new global::VRGIN.Helpers.JSONArray());
                                bool flag7 = jsonnode != null;
                                if (flag7)
                                {
                                    text2 = text2.Trim();
                                    bool flag8 = jsonnode is global::VRGIN.Helpers.JSONArray;
                                    if (flag8)
                                    {
                                        jsonnode.Add(stack.Peek());
                                    }
                                    else
                                    {
                                        bool flag9 = text2 != "";
                                        if (flag9)
                                        {
                                            jsonnode.Add(text2, stack.Peek());
                                        }
                                    }
                                }
                                text2    = "";
                                text     = "";
                                jsonnode = stack.Peek();
                                goto IL_473;
                            }

                            case '\\':
                            {
                                i++;
                                bool flag10 = flag;
                                if (flag10)
                                {
                                    char c3 = aJSON.get_Chars(i);
                                    char c4 = c3;
                                    char c5 = c4;
                                    if (c5 <= 'f')
                                    {
                                        if (c5 != 'b')
                                        {
                                            if (c5 != 'f')
                                            {
                                                goto IL_447;
                                            }
                                            text += "\f";
                                        }
                                        else
                                        {
                                            text += "\b";
                                        }
                                    }
                                    else if (c5 != 'n')
                                    {
                                        switch (c5)
                                        {
                                        case 'r':
                                            text += "\r";
                                            break;

                                        case 's':
                                            goto IL_447;

                                        case 't':
                                            text += "\t";
                                            break;

                                        case 'u':
                                        {
                                            string text3 = aJSON.Substring(i + 1, 4);
                                            text += ((char)int.Parse(text3, 512)).ToString();
                                            i    += 4;
                                            break;
                                        }

                                        default:
                                            goto IL_447;
                                        }
                                    }
                                    else
                                    {
                                        text += "\n";
                                    }
                                    goto IL_458;
IL_447:
                                    text += c3.ToString();
                                }
IL_458:
                                goto IL_473;
                            }

                            case ']':
                                break;

                            default:
                                goto IL_45A;
                            }
                        }
                        else
                        {
                            bool flag11 = flag;
                            if (flag11)
                            {
                                text += aJSON.get_Chars(i).ToString();
                                goto IL_473;
                            }
                            text2 = text;
                            text  = "";
                            flag2 = false;
                            goto IL_473;
                        }
                    }
                    else if (c2 != '{')
                    {
                        if (c2 != '}')
                        {
                            goto IL_45A;
                        }
                    }
                    else
                    {
                        bool flag12 = flag;
                        if (flag12)
                        {
                            text += aJSON.get_Chars(i).ToString();
                            goto IL_473;
                        }
                        stack.Push(new global::VRGIN.Helpers.JSONClass());
                        bool flag13 = jsonnode != null;
                        if (flag13)
                        {
                            text2 = text2.Trim();
                            bool flag14 = jsonnode is global::VRGIN.Helpers.JSONArray;
                            if (flag14)
                            {
                                jsonnode.Add(stack.Peek());
                            }
                            else
                            {
                                bool flag15 = text2 != "";
                                if (flag15)
                                {
                                    jsonnode.Add(text2, stack.Peek());
                                }
                            }
                        }
                        text2    = "";
                        text     = "";
                        jsonnode = stack.Peek();
                        goto IL_473;
                    }
                    bool flag16 = flag;
                    if (flag16)
                    {
                        text += aJSON.get_Chars(i).ToString();
                    }
                    else
                    {
                        bool flag17 = stack.Count == 0;
                        if (flag17)
                        {
                            throw new global::System.Exception("JSON Parse: Too many closing brackets");
                        }
                        stack.Pop();
                        bool flag18 = text != "";
                        if (flag18)
                        {
                            text2 = text2.Trim();
                            global::VRGIN.Helpers.JSONNode.AddElement(jsonnode, text, text2, flag2);
                            flag2 = false;
                        }
                        text2 = "";
                        text  = "";
                        bool flag19 = stack.Count > 0;
                        if (flag19)
                        {
                            jsonnode = stack.Peek();
                        }
                    }
                }
IL_473:
                i++;
                continue;
IL_45A:
                text += aJSON.get_Chars(i).ToString();
                goto IL_473;
            }
            bool flag20 = flag;

            if (flag20)
            {
                throw new global::System.Exception("JSON Parse: Quotation marks seems to be messed up.");
            }
            return(jsonnode);
        }