protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            JSONValue value5 = dict["groups"];

            foreach (JSONValue value2 in value5.AsList(true))
            {
                Group group = Group.Create();
                this.ParseList(value2, ref group);
                this.groups.Add(group);
            }
            JSONValue        value6 = dict["query"];
            JSONValue        value3 = value6["offsets"];
            JSONValue        value7 = dict["query"];
            List <JSONValue> list   = value7["limits"].AsList(true);
            int num = 0;

            foreach (JSONValue value4 in value3.AsList(true))
            {
                Group group2 = this.groups[num];
                group2.offset = (int)value4.AsFloat(true);
                JSONValue value9 = list[num];
                group2.limit     = (int)value9.AsFloat(true);
                this.groups[num] = group2;
                num++;
            }
        }
Exemple #2
0
    private static string RefreshMainAssets(JSONValue jval, Package package)
    {
        string str;
        string str1 = "unknown";

        try
        {
            str1 = "assetbundles";
            JSONValue jSONValue = jval.Get(str1);
            if (!jSONValue.IsNull())
            {
                List <string> strs = new List <string>();
                foreach (JSONValue jSONValue1 in jSONValue.AsList(false))
                {
                    strs.Add(jSONValue1.AsString(false));
                }

                package.MainAssets = strs;
            }

            return(null);
        }
        catch (JSONTypeException jSONTypeException1)
        {
            JSONTypeException jSONTypeException = jSONTypeException1;
            str = string.Concat(new string[] { "Malformed metadata response for mainAssets '", package.Name, "' field '", str1, "': ", jSONTypeException.Message });
        }
        catch (KeyNotFoundException keyNotFoundException1)
        {
            KeyNotFoundException keyNotFoundException = keyNotFoundException1;
            str = string.Concat(new string[] { "Malformed metadata response for package. '", package.Name, "' field '", str1, "': ", keyNotFoundException.Message });
        }

        return(str);
    }
Exemple #3
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;
                }
            }
        }
    private static string RefreshMainAssets(JSONValue jval, Package package)
    {
        string text = "unknown";

        try
        {
            text = "assetbundles";
            JSONValue jSONValue = jval.Get(text);
            if (!jSONValue.IsNull())
            {
                List <string>    list  = new List <string>();
                List <JSONValue> list2 = jSONValue.AsList(false);
                foreach (JSONValue current in list2)
                {
                    list.Add(current.AsString(false));
                }
                package.MainAssets = list;
            }
        }
        catch (JSONTypeException ex)
        {
            string result = string.Concat(new string[]
            {
                "Malformed metadata response for mainAssets '",
                package.Name,
                "' field '",
                text,
                "': ",
                ex.Message
            });
            return(result);
        }
        catch (KeyNotFoundException ex2)
        {
            string result = string.Concat(new string[]
            {
                "Malformed metadata response for package. '",
                package.Name,
                "' field '",
                text,
                "': ",
                ex2.Message
            });
            return(result);
        }
        return(null);
    }
        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++;
            }
        }
        protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            foreach (JSONValue v in dict["groups"].AsList(true))
            {
                Group group = Group.Create();
                ParseList(v, ref group);
                groups.Add(group);
            }
            JSONValue        offsets = dict["query"]["offsets"];
            List <JSONValue> limits  = dict["query"]["limits"].AsList(true);
            int idx = 0;

            foreach (JSONValue v in offsets.AsList(true))
            {
                Group g = groups[idx];
                g.offset    = (int)v.AsFloat(true);
                g.limit     = (int)limits[idx].AsFloat(true);
                groups[idx] = g;
                idx++;
            }
        }
        private void ParseList(JSONValue matches, ref Group group)
        {
            List <AssetStoreAsset> assets = group.assets;

            if (matches.ContainsKey("error"))
            {
                base.error = matches["error"].AsString(true);
            }
            if (matches.ContainsKey("warnings"))
            {
                base.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);
            }
            if (group.label == null)
            {
            }
            group.label = group.name;
            if (matches.ContainsKey("total_found"))
            {
                JSONValue value7 = matches["total_found"];
                group.totalFound = (int)value7.AsFloat(true);
            }
            if (matches.ContainsKey("matches"))
            {
                JSONValue value8 = matches["matches"];
                foreach (JSONValue value2 in value8.AsList(true))
                {
                    AssetStoreAsset item = new AssetStoreAsset();
                    if ((value2.ContainsKey("id") && value2.ContainsKey("name")) && value2.ContainsKey("package_id"))
                    {
                        JSONValue value9 = value2["id"];
                        item.id          = (int)value9.AsFloat();
                        item.name        = value2["name"].AsString();
                        item.displayName = StripExtension(item.name);
                        JSONValue value11 = value2["package_id"];
                        item.packageID = (int)value11.AsFloat();
                        if (value2.ContainsKey("static_preview_url"))
                        {
                            item.staticPreviewURL = value2["static_preview_url"].AsString();
                        }
                        if (value2.ContainsKey("dynamic_preview_url"))
                        {
                            item.dynamicPreviewURL = value2["dynamic_preview_url"].AsString();
                        }
                        item.className = !value2.ContainsKey("class_name") ? string.Empty : value2["class_name"].AsString();
                        if (value2.ContainsKey("price"))
                        {
                            item.price = value2["price"].AsString();
                        }
                        assets.Add(item);
                    }
                }
            }
        }
        protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            Dictionary <string, JSONValue> dictionary = dict["purchase_info"].AsDict(true);
            JSONValue value4 = dictionary["status"];

            switch (value4.AsString(true))
            {
            case "basket-not-empty":
                this.status = Status.BasketNotEmpty;
                break;

            case "service-disabled":
                this.status = Status.ServiceDisabled;
                break;

            case "user-anonymous":
                this.status = Status.AnonymousUser;
                break;

            case "ok":
                this.status = Status.Ok;
                break;
            }
            this.paymentTokenAvailable = dictionary["payment_token_available"].AsBool();
            if (dictionary.ContainsKey("payment_method_card"))
            {
                this.paymentMethodCard = dictionary["payment_method_card"].AsString(true);
            }
            if (dictionary.ContainsKey("payment_method_expire"))
            {
                this.paymentMethodExpire = dictionary["payment_method_expire"].AsString(true);
            }
            this.price     = dictionary["price"].AsFloat(true);
            this.vat       = dictionary["vat"].AsFloat(true);
            this.priceText = dictionary["price_text"].AsString(true);
            this.vatText   = dictionary["vat_text"].AsString(true);
            this.currency  = dictionary["currency"].AsString(true);
            this.message   = !dictionary.ContainsKey("message") ? null : dictionary["message"].AsString(true);
            JSONValue value14 = dict["results"];

            foreach (JSONValue value2 in value14.AsList(true))
            {
                AssetStoreAsset asset;
                int             key     = 0;
                JSONValue       value15 = value2["id"];
                if (value15.IsString())
                {
                    key = int.Parse(value2["id"].AsString());
                }
                else
                {
                    JSONValue value17 = value2["id"];
                    key = (int)value17.AsFloat();
                }
                if (this.assets.TryGetValue(key, out asset))
                {
                    JSONValue value27;
                    if (asset.previewInfo == null)
                    {
                        asset.previewInfo = new AssetStoreAsset.PreviewInfo();
                    }
                    AssetStoreAsset.PreviewInfo previewInfo = asset.previewInfo;
                    JSONValue value18 = value2["class_names"];
                    asset.className = value18.AsString(true).Trim();
                    JSONValue value19 = value2["package_name"];
                    previewInfo.packageName = value19.AsString(true).Trim();
                    JSONValue value20 = value2["short_url"];
                    previewInfo.packageShortUrl = value20.AsString(true).Trim();
                    asset.price                = !value2.ContainsKey("price_text") ? null : value2["price_text"].AsString(true).Trim();
                    previewInfo.packageSize    = int.Parse(!value2.Get("package_size").IsNull() ? value2["package_size"].AsString(true) : "-1");
                    asset.packageID            = int.Parse(value2["package_id"].AsString());
                    previewInfo.packageVersion = value2["package_version"].AsString();
                    if (!value2.Get("rating").IsNull())
                    {
                        value27 = value2["rating"];
                    }
                    previewInfo.packageRating = int.Parse((value27.AsString(true).Length != 0) ? value2["rating"].AsString(true) : "-1");
                    JSONValue value29 = value2["package_asset_count"];
                    previewInfo.packageAssetCount = int.Parse(!value29.IsNull() ? value2["package_asset_count"].AsString(true) : "-1");
                    previewInfo.isPurchased       = value2.ContainsKey("purchased") && value2["purchased"].AsBool(true);
                    previewInfo.isDownloadable    = previewInfo.isPurchased || (asset.price == null);
                    JSONValue value32 = value2["publisher_name"];
                    previewInfo.publisherName    = value32.AsString(true).Trim();
                    previewInfo.packageUrl       = !value2.Get("package_url").IsNull() ? value2["package_url"].AsString(true) : string.Empty;
                    previewInfo.encryptionKey    = !value2.Get("encryption_key").IsNull() ? value2["encryption_key"].AsString(true) : string.Empty;
                    previewInfo.categoryName     = !value2.Get("category_name").IsNull() ? value2["category_name"].AsString(true) : string.Empty;
                    previewInfo.buildProgress    = -1f;
                    previewInfo.downloadProgress = -1f;
                }
            }
        }