Esempio n. 1
0
 private SolidColorBrush GetIconColor(JsonItemType type)
 {
     if (type == JsonItemType.Object)
     {
         return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
     }
     else if (type == JsonItemType.Array)
     {
         return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
     }
     else if (type == JsonItemType.String)
     {
         return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
     }
     else if (type == JsonItemType.Number)
     {
         return(new SolidColorBrush(Color.FromRgb(0, 177, 106)));
     }
     else if (type == JsonItemType.Boolean)
     {
         return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
     }
     else if (type == JsonItemType.Null)
     {
         return(new SolidColorBrush(Color.FromRgb(207, 0, 15)));
     }
     else
     {
         return(new SolidColorBrush(Color.FromRgb(0, 0, 0)));
     }
 }
Esempio n. 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            JsonItemType type = (JsonItemType)value;

            if (type == JsonItemType.Object)
            {
                return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
            }
            else if (type == JsonItemType.Array)
            {
                return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
            }
            else if (type == JsonItemType.String)
            {
                return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
            }
            else if (type == JsonItemType.Number)
            {
                return(new SolidColorBrush(Color.FromRgb(0, 177, 106)));
            }
            else if (type == JsonItemType.Boolean)
            {
                return(new SolidColorBrush(Color.FromRgb(31, 58, 147)));
            }
            else if (type == JsonItemType.Null)
            {
                return(new SolidColorBrush(Color.FromRgb(207, 0, 15)));
            }
            else
            {
                return(new SolidColorBrush(Color.FromRgb(0, 0, 0)));
            }
        }
Esempio n. 3
0
 private PackIconMaterialKind GetIcon(JsonItemType type)
 {
     if (type == JsonItemType.Object)
     {
         return(PackIconMaterialKind.CodeBraces);
     }
     else if (type == JsonItemType.Array)
     {
         return(PackIconMaterialKind.CodeBrackets);
     }
     else
     {
         return(PackIconMaterialKind.SquareRounded);
     }
 }
Esempio n. 4
0
        private List <JsonItem> JsonDecode(JsonItemType objtype, JsonItem parent)
        {
            StringBuilder key              = new StringBuilder();
            StringBuilder value            = new StringBuilder();
            StringBuilder comment          = new StringBuilder();
            bool          inquot           = false;
            bool          quoted           = false;
            bool          isspec           = false;
            bool          splitterFound    = false;
            bool          inlinecomment    = false;
            bool          multilinecomment = false;
            int           lineoffset       = 0;
            char          quotchar         = '\0';
            JsonItem      lastitem         = new JsonItem
            {
                Parent    = parent,
                NameQuot  = '\0',
                ValueQuot = '\0'
            };
            List <JsonItem> items    = new List <JsonItem>();
            List <JsonItem> comments = new List <JsonItem>();

            for (int i = this.startid; i < this.input.Length; i++)
            {
                char cur  = this.input[i];
                char next = (i + 1 < this.input.Length) ? this.input[i + 1] : '\0';
                bool flag = inlinecomment || multilinecomment;
                if (flag)
                {
                    bool flag2 = inlinecomment;
                    if (flag2)
                    {
                        bool flag3 = cur == '\r' && next == '\n';
                        if (flag3)
                        {
                            goto IL_87B;
                        }
                    }
                    bool flag4 = (inlinecomment && cur == '\n') || (multilinecomment && cur == '*' && next == '/');
                    if (flag4)
                    {
                        bool flag5 = multilinecomment;
                        if (flag5)
                        {
                            i++;
                        }
                        bool flag6 = !this.skipComment;
                        if (flag6)
                        {
                            JsonItem commentItem = new JsonItem
                            {
                                LineOffset = lineoffset,
                                Value      = comment.ToString(),
                                ObjectType = (inlinecomment ? JsonItemType.OBJ_COMMENT_SINGLELINE : JsonItemType.OBJ_COMMENT_MULTILINE),
                                Parent     = parent,
                                NameQuot   = '\0',
                                ValueQuot  = '\0',
                                Index      = items.Count
                            };
                            bool flag7 = key.Length > 0 || splitterFound;
                            if (flag7)
                            {
                                comments.Add(commentItem);
                            }
                            else
                            {
                                items.Add(commentItem);
                            }
                            comment.Clear();
                        }
                        inlinecomment    = false;
                        multilinecomment = false;
                    }
                    else
                    {
                        bool flag8 = !this.skipComment;
                        if (flag8)
                        {
                            comment.Append(cur);
                        }
                    }
                }
                else
                {
                    bool flag9 = isspec;
                    if (flag9)
                    {
                        bool flag10 = this.DecodeUnicode && (cur == 'u' || cur == 'U') && i + 5 < this.input.Length;
                        if (flag10)
                        {
                            bool  contn = true;
                            int[] nums  = new int[4];
                            for (int j = 1; j < 5; j++)
                            {
                                char ucur   = this.input[i + j];
                                bool flag11 = !Uri.IsHexDigit(ucur);
                                if (flag11)
                                {
                                    contn = false;
                                    break;
                                }
                                nums[j - 1] = Uri.FromHex(ucur);
                            }
                            bool flag12 = contn;
                            if (flag12)
                            {
                                int formula = nums[0] * 16 * 16 * 16 + nums[1] * 16 * 16 + nums[2] * 16 + nums[3];
                                i  += 4;
                                cur = (char)formula;
                            }
                        }
                        bool flag13 = splitterFound;
                        if (flag13)
                        {
                            value.Append(cur);
                        }
                        else
                        {
                            key.Append(cur);
                        }
                        isspec = false;
                    }
                    else
                    {
                        bool flag14 = cur == '\\' && !isspec;
                        if (flag14)
                        {
                            isspec = true;
                        }
                        else
                        {
                            bool flag15 = cur == '/';
                            if (flag15)
                            {
                                bool flag16 = next == '/';
                                if (flag16)
                                {
                                    inlinecomment = true;
                                    i++;
                                    goto IL_87B;
                                }
                                bool flag17 = next == '*';
                                if (flag17)
                                {
                                    multilinecomment = true;
                                    i++;
                                    goto IL_87B;
                                }
                            }
                            bool flag18 = inquot;
                            if (flag18)
                            {
                                bool flag19 = cur == quotchar;
                                if (flag19)
                                {
                                    inquot = false;
                                    quoted = true;
                                    bool flag20 = objtype == JsonItemType.OBJ_ARRAY;
                                    if (flag20)
                                    {
                                        lastitem.ValueQuot = quotchar;
                                    }
                                    else
                                    {
                                        bool flag21 = objtype == JsonItemType.OBJ_OBJECT;
                                        if (flag21)
                                        {
                                            bool flag22 = splitterFound;
                                            if (flag22)
                                            {
                                                lastitem.ValueQuot = quotchar;
                                            }
                                            else
                                            {
                                                lastitem.NameQuot = quotchar;
                                            }
                                        }
                                    }
                                    goto IL_87B;
                                }
                                bool flag23 = !splitterFound;
                                if (flag23)
                                {
                                    key.Append(cur);
                                }
                                else
                                {
                                    value.Append(cur);
                                }
                            }
                            else
                            {
                                bool flag24 = cur == '"' || cur == '\'';
                                if (flag24)
                                {
                                    quotchar = cur;
                                    inquot   = true;
                                    goto IL_87B;
                                }
                            }
                            bool flag25 = !inquot;
                            if (flag25)
                            {
                                char c = cur;
                                if (c <= ':')
                                {
                                    if (c <= ' ')
                                    {
                                        switch (c)
                                        {
                                        case '\t':
                                        case '\n':
                                        case '\r':
                                            break;

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

                                        default:
                                            if (c != ' ')
                                            {
                                                goto IL_842;
                                            }
                                            break;
                                        }
                                        bool flag26 = cur == '\n' || (cur == '\r' && next != '\n');
                                        if (flag26)
                                        {
                                            lineoffset++;
                                        }
                                    }
                                    else if (c != ',')
                                    {
                                        if (c != ':')
                                        {
                                            goto IL_842;
                                        }
                                        bool flag27 = splitterFound || objtype == JsonItemType.OBJ_ARRAY || objtype == JsonItemType.OBJ_NONE;
                                        if (flag27)
                                        {
                                            this.stopFailure = true;
                                            return(null);
                                        }
                                        lastitem.Name = key.ToString();
                                        splitterFound = true;
                                        quoted        = false;
                                        inquot        = false;
                                    }
                                    else
                                    {
                                        bool flag28 = !splitterFound && objtype == JsonItemType.OBJ_OBJECT;
                                        if (flag28)
                                        {
                                            this.stopFailure = true;
                                            return(null);
                                        }
                                        bool flag29 = objtype == JsonItemType.OBJ_ARRAY;
                                        if (flag29)
                                        {
                                            bool flag30 = key.Length > 0 || quoted;
                                            if (flag30)
                                            {
                                                lastitem.Value      = key.ToString();
                                                lastitem.ObjectType = JsonItemType.OBJ_ARRAYITEM;
                                            }
                                        }
                                        else
                                        {
                                            bool flag31 = objtype == JsonItemType.OBJ_OBJECT;
                                            if (flag31)
                                            {
                                                bool flag32 = value.Length > 0 || quoted;
                                                if (flag32)
                                                {
                                                    lastitem.Value      = value.ToString();
                                                    lastitem.ObjectType = JsonItemType.OBJ_VARIANT;
                                                }
                                            }
                                        }
                                        lastitem.Index = items.Count;
                                        items.Add(lastitem);
                                        bool flag33 = comments.Count > 0;
                                        if (flag33)
                                        {
                                            items.AddRange(comments);
                                            comments.Clear();
                                        }
                                        key.Clear();
                                        value.Clear();
                                        inquot        = false;
                                        quoted        = false;
                                        splitterFound = false;
                                        lastitem      = new JsonItem
                                        {
                                            NameQuot  = '\0',
                                            ValueQuot = '\0',
                                            Parent    = parent
                                        };
                                    }
                                }
                                else
                                {
                                    if (c <= ']')
                                    {
                                        if (c != '[')
                                        {
                                            if (c != ']')
                                            {
                                                goto IL_842;
                                            }
                                            goto IL_570;
                                        }
                                    }
                                    else if (c != '{')
                                    {
                                        if (c != '}')
                                        {
                                            goto IL_842;
                                        }
                                        goto IL_570;
                                    }
                                    bool flag34 = !splitterFound && key.Length > 0;
                                    if (flag34)
                                    {
                                        this.stopFailure = true;
                                        return(null);
                                    }
                                    bool flag35 = value.Length > 0;
                                    if (flag35)
                                    {
                                        this.stopFailure = true;
                                        return(null);
                                    }
                                    this.startid = i + 1;
                                    this.depth++;
                                    bool flag36 = cur == '{';
                                    if (flag36)
                                    {
                                        bool flag37 = !splitterFound && objtype == JsonItemType.OBJ_OBJECT;
                                        if (flag37)
                                        {
                                            this.stopFailure = true;
                                            return(null);
                                        }
                                        this.depth_object++;
                                        lastitem.ObjectType = JsonItemType.OBJ_OBJECT;
                                        lastitem.SubItems   = this.JsonDecode(JsonItemType.OBJ_OBJECT, lastitem);
                                    }
                                    else
                                    {
                                        this.depth_array++;
                                        lastitem.ObjectType = JsonItemType.OBJ_ARRAY;
                                        lastitem.SubItems   = this.JsonDecode(JsonItemType.OBJ_ARRAY, lastitem);
                                    }
                                    bool flag38 = this.stopFailure;
                                    if (flag38)
                                    {
                                        return(null);
                                    }
                                    i = this.startid;
                                    goto IL_879;
IL_570:
                                    bool flag39 = (objtype == JsonItemType.OBJ_OBJECT && !splitterFound && key.Length > 0) || (value.Length > 0 && objtype == JsonItemType.OBJ_ARRAY);
                                    if (flag39)
                                    {
                                        this.stopFailure = true;
                                        return(null);
                                    }
                                    this.startid = i;
                                    bool flag40 = cur == '}';
                                    if (flag40)
                                    {
                                        this.depth_object--;
                                    }
                                    else
                                    {
                                        this.depth_array--;
                                    }
                                    this.depth--;
                                    bool flag41 = this.depth_array < 0 || this.depth_object < 0 || this.depth < 0;
                                    if (flag41)
                                    {
                                        this.stopFailure = true;
                                        return(null);
                                    }
                                    bool flag42 = objtype == JsonItemType.OBJ_ARRAY;
                                    if (flag42)
                                    {
                                        bool flag43 = key.Length > 0;
                                        if (flag43)
                                        {
                                            lastitem.ObjectType = JsonItemType.OBJ_ARRAYITEM;
                                            lastitem.Value      = key.ToString();
                                        }
                                    }
                                    else
                                    {
                                        bool flag44 = objtype == JsonItemType.OBJ_OBJECT;
                                        if (flag44)
                                        {
                                            bool flag45 = value.Length > 0;
                                            if (flag45)
                                            {
                                                lastitem.ObjectType = JsonItemType.OBJ_VARIANT;
                                                lastitem.Value      = value.ToString();
                                            }
                                        }
                                    }
                                    lastitem.Index = items.Count;
                                    items.Add(lastitem);
                                    bool flag46 = comments.Count > 0;
                                    if (flag46)
                                    {
                                        items.AddRange(comments);
                                        comments.Clear();
                                    }
                                    return(items);
                                }
IL_879:
                                goto IL_87A;
IL_842:
                                if (!quoted)
                                {
                                    if (splitterFound)
                                    {
                                        value.Append(cur);
                                    }
                                    else
                                    {
                                        key.Append(cur);
                                    }
                                    goto IL_879;
                                }
                                this.stopFailure = true;
                                return(null);
                            }
                            IL_87A :;
                        }
                    }
                }
                IL_87B :;
            }
            return(lastitem.SubItems);
        }