public static IEnumerable <string> GetVariables(JSONParseItem item)
        {
            var visitor = new JSONItemCollector <JSONMember>(true);

            if (!item.JSONDocument.Accept(visitor))
            {
                return(null);
            }

            var           contents = visitor.Items.Where(m => m.UnquotedNameText == "content" && m.IsValid);
            List <string> list     = new List <string>();

            foreach (JSONMember content in contents)
            {
                var value = content?.Value as JSONObject;

                if (value == null)
                {
                    continue;
                }

                var names = value.Children.OfType <JSONMember>().Select(s => s.UnquotedNameText);

                list.AddRange(names.Where(n => !list.Contains(n)));
            }

            return(list);
        }
Beispiel #2
0
        public static IDictionary <string, string> GetIcons(JSONParseItem item)
        {
            var visitor = new JSONItemCollector <JSONMember>(true);
            var dic     = new Dictionary <string, string>();

            if (!item.JSONDocument.Accept(visitor))
            {
                return(dic);
            }

            var icons = visitor.Items.FirstOrDefault(m => m.UnquotedNameText == "icons");
            var value = icons?.Value as JSONObject;

            if (value == null)
            {
                return(dic);
            }

            string folder = Path.GetDirectoryName(item.JSONDocument.DocumentLocation);

            foreach (JSONMember icon in value.Children.OfType <JSONMember>())
            {
                dic.Add(icon.UnquotedNameText, icon.UnquotedValueText);
            }

            return(dic);
        }