Exemple #1
0
        protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            using (List <JSONValue> .Enumerator enumerator = dict["groups"].AsList(true).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    JSONValue current = enumerator.Current;
                    AssetStoreSearchResults.Group group = AssetStoreSearchResults.Group.Create();
                    this.ParseList(current, ref group);
                    this.groups.Add(group);
                }
            }
            JSONValue        jsonValue     = dict["query"]["offsets"];
            List <JSONValue> jsonValueList = dict["query"]["limits"].AsList(true);
            int index = 0;

            using (List <JSONValue> .Enumerator enumerator = jsonValue.AsList(true).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    JSONValue current = enumerator.Current;
                    AssetStoreSearchResults.Group group = this.groups[index];
                    group.offset       = (int)current.AsFloat(true);
                    group.limit        = (int)jsonValueList[index].AsFloat(true);
                    this.groups[index] = group;
                    ++index;
                }
            }
        }
Exemple #2
0
        private void ParseList(JSONValue matches, ref AssetStoreSearchResults.Group group)
        {
            List <AssetStoreAsset> assets = group.assets;

            if (matches.ContainsKey("error"))
            {
                this.error = matches["error"].AsString(true);
            }
            if (matches.ContainsKey("warnings"))
            {
                this.warnings = matches["warnings"].AsString(true);
            }
            if (matches.ContainsKey("name"))
            {
                group.name = matches["name"].AsString(true);
            }
            if (matches.ContainsKey("label"))
            {
                group.label = matches["label"].AsString(true);
            }
            group.label = group.label ?? group.name;
            if (matches.ContainsKey("total_found"))
            {
                group.totalFound = (int)matches["total_found"].AsFloat(true);
            }
            if (!matches.ContainsKey("matches"))
            {
                return;
            }
            using (List <JSONValue> .Enumerator enumerator = matches["matches"].AsList(true).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    JSONValue       current         = enumerator.Current;
                    AssetStoreAsset assetStoreAsset = new AssetStoreAsset();
                    if (current.ContainsKey("id") && current.ContainsKey("name") && current.ContainsKey("package_id"))
                    {
                        assetStoreAsset.id          = (int)current["id"].AsFloat();
                        assetStoreAsset.name        = current["name"].AsString();
                        assetStoreAsset.displayName = AssetStoreSearchResults.StripExtension(assetStoreAsset.name);
                        assetStoreAsset.packageID   = (int)current["package_id"].AsFloat();
                        if (current.ContainsKey("static_preview_url"))
                        {
                            assetStoreAsset.staticPreviewURL = current["static_preview_url"].AsString();
                        }
                        if (current.ContainsKey("dynamic_preview_url"))
                        {
                            assetStoreAsset.dynamicPreviewURL = current["dynamic_preview_url"].AsString();
                        }
                        assetStoreAsset.className = !current.ContainsKey("class_name") ? string.Empty : current["class_name"].AsString();
                        if (current.ContainsKey("price"))
                        {
                            assetStoreAsset.price = current["price"].AsString();
                        }
                        assets.Add(assetStoreAsset);
                    }
                }
            }
        }
        private void ParseList(JSONValue matches, ref AssetStoreSearchResults.Group group)
        {
            List <AssetStoreAsset> assets = group.assets;

            if (matches.ContainsKey("error"))
            {
                this.error = matches["error"].AsString(true);
            }
            if (matches.ContainsKey("warnings"))
            {
                this.warnings = matches["warnings"].AsString(true);
            }
            if (matches.ContainsKey("name"))
            {
                group.name = matches["name"].AsString(true);
            }
            if (matches.ContainsKey("label"))
            {
                group.label = matches["label"].AsString(true);
            }
            group.label = (group.label ?? group.name);
            if (matches.ContainsKey("total_found"))
            {
                group.totalFound = (int)matches["total_found"].AsFloat(true);
            }
            if (matches.ContainsKey("matches"))
            {
                foreach (JSONValue current in matches["matches"].AsList(true))
                {
                    AssetStoreAsset assetStoreAsset = new AssetStoreAsset();
                    if (current.ContainsKey("id") && current.ContainsKey("name") && current.ContainsKey("package_id"))
                    {
                        assetStoreAsset.id          = (int)current["id"].AsFloat();
                        assetStoreAsset.name        = current["name"].AsString();
                        assetStoreAsset.displayName = AssetStoreSearchResults.StripExtension(assetStoreAsset.name);
                        assetStoreAsset.packageID   = (int)current["package_id"].AsFloat();
                        if (current.ContainsKey("static_preview_url"))
                        {
                            assetStoreAsset.staticPreviewURL = current["static_preview_url"].AsString();
                        }
                        if (current.ContainsKey("dynamic_preview_url"))
                        {
                            assetStoreAsset.dynamicPreviewURL = current["dynamic_preview_url"].AsString();
                        }
                        assetStoreAsset.className = ((!current.ContainsKey("class_name")) ? "" : current["class_name"].AsString());
                        if (current.ContainsKey("price"))
                        {
                            assetStoreAsset.price = current["price"].AsString();
                        }
                        assets.Add(assetStoreAsset);
                    }
                }
            }
        }
        protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            foreach (JSONValue current in dict["groups"].AsList(true))
            {
                AssetStoreSearchResults.Group item = AssetStoreSearchResults.Group.Create();
                this.ParseList(current, ref item);
                this.groups.Add(item);
            }
            JSONValue        jSONValue = dict["query"]["offsets"];
            List <JSONValue> list      = dict["query"]["limits"].AsList(true);
            int num = 0;

            foreach (JSONValue current2 in jSONValue.AsList(true))
            {
                AssetStoreSearchResults.Group value = this.groups[num];
                value.offset     = (int)current2.AsFloat(true);
                value.limit      = (int)list[num].AsFloat(true);
                this.groups[num] = value;
                num++;
            }
        }