private JSONValue ParseDict() { this.Next(); this.SkipWs(); Dictionary <string, JSONValue> dictionary = new Dictionary <string, JSONValue>(); while (this.cur != '}') { JSONValue jSONValue = this.ParseValue(); if (!jSONValue.IsString()) { throw new JSONParseException("Key not string type at " + this.PosMsg()); } this.SkipWs(); if (this.cur != ':') { throw new JSONParseException("Missing dict entry delimiter ':' at " + this.PosMsg()); } this.Next(); dictionary.Add(jSONValue.AsString(false), this.ParseValue()); this.SkipWs(); if (this.cur == ',') { this.Next(); this.SkipWs(); } } this.Next(); return(new JSONValue(dictionary)); }
public PackageList GetPackageList() { Dictionary <string, Package> dictionary = new Dictionary <string, Package>(); PackageInfo[] packageList = PackageInfo.GetPackageList(); foreach (PackageInfo info in packageList) { Package package = new Package(); if (info.jsonInfo == "") { package.title = Path.GetFileNameWithoutExtension(info.packagePath); package.id = info.packagePath; if (this.IsBuiltinStandardAsset(info.packagePath)) { LabelAndId id = new LabelAndId { label = "Unity Technologies", id = "1" }; package.publisher = id; id = new LabelAndId { label = "Prefab Packages", id = "4" }; package.category = id; package.version = "3.5.0.0"; } } else { JSONValue json = JSONParser.SimpleParse(info.jsonInfo); if (json.IsNull()) { continue; } package.Initialize(json); if (package.id == null) { JSONValue value3 = json.Get("link.id"); if (!value3.IsNull()) { package.id = value3.AsString(); } else { package.id = info.packagePath; } } } package.local_icon = info.iconURL; package.local_path = info.packagePath; if (((!dictionary.ContainsKey(package.id) || (dictionary[package.id].version_id == null)) || (dictionary[package.id].version_id == "-1")) || (((package.version_id != null) && (package.version_id != "-1")) && (int.Parse(dictionary[package.id].version_id) <= int.Parse(package.version_id)))) { dictionary[package.id] = package; } } Package[] packageArray = dictionary.Values.ToArray <Package>(); return(new PackageList { results = packageArray }); }
private JSONValue ParseDict() { this.Next(); this.SkipWs(); Dictionary <string, JSONValue> strs = new Dictionary <string, JSONValue>(); while (this.cur != '}') { JSONValue jSONValue = this.ParseValue(); if (!jSONValue.IsString()) { throw new JSONParseException(string.Concat("Key not string type at ", this.PosMsg())); } this.SkipWs(); if (this.cur != ':') { throw new JSONParseException(string.Concat("Missing dict entry delimiter ':' at ", this.PosMsg())); } this.Next(); strs.Add(jSONValue.AsString(false), this.ParseValue()); this.SkipWs(); if (this.cur != ',') { continue; } this.Next(); this.SkipWs(); } this.Next(); return(new JSONValue(strs)); }
public bool Copy(string key, ref string dest, bool allowCopyNull) { bool flag; JSONValue jSONValue = this.Get(key, out flag); if (flag && (!jSONValue.IsNull() || allowCopyNull)) { dest = ((!jSONValue.IsNull()) ? jSONValue.AsString(false) : null); } return(flag); }
private static string OnAssetStorePublisher(JSONValue jval, AssetStorePublisher account, PackageDataSource packageDataSource) { string str; string str1 = "unknown field"; try { str1 = "publisher"; Dictionary <string, JSONValue> strs = jval["publisher"].AsDict(false); account.mStatus = AssetStorePublisher.Status.New; if (strs.ContainsKey("name")) { account.mStatus = AssetStorePublisher.Status.Existing; str1 = "publisher -> id"; JSONValue item = strs["id"]; account.publisherId = int.Parse(item.AsString(false)); str1 = "publisher -> name"; account.publisherName = strs["name"].AsString(false); } str1 = "publisher"; if (AssetStoreManager.sDbg) { JSONValue jSONValue = jval["publisher"]; DebugUtils.Log(string.Concat("publisher ", jSONValue.ToString(string.Empty, " "))); JSONValue item1 = jval["packages"]; DebugUtils.Log(string.Concat("packs ", item1.ToString(string.Empty, " "))); } str1 = "packages"; if (!jval.Get("packages").IsNull()) { AssetStoreAPI.OnPackages(jval["packages"], packageDataSource); } return(null); } catch (JSONTypeException jSONTypeException1) { JSONTypeException jSONTypeException = jSONTypeException1; str = string.Concat("Malformed response from server: ", str1, " - ", jSONTypeException.Message); } catch (KeyNotFoundException keyNotFoundException1) { KeyNotFoundException keyNotFoundException = keyNotFoundException1; str = string.Concat("Malformed response from server. ", str1, " - ", keyNotFoundException.Message); } return(str); }
public bool Copy(string key, ref string dest, bool allowCopyNull) { bool flag; string str; JSONValue jSONValue = this.Get(key, out flag); if (flag && (!jSONValue.IsNull() || allowCopyNull)) { if (!jSONValue.IsNull()) { str = jSONValue.AsString(false); } else { str = null; } dest = str; } return(flag); }
private static bool Parse(AssetStoreResponse response, out string error, out JSONValue jval) { bool flag; jval = new JSONValue(); error = null; if (response.failed) { error = string.Format("Error receiving response from server ({0}): {1}", response.HttpStatusCode, response.HttpErrorMessage ?? "n/a"); return(true); } try { jval = (new JSONParser(response.data)).Parse(); if (jval.ContainsKey("error")) { JSONValue item = jval["error"]; error = item.AsString(true); } else if (jval.ContainsKey("status") && jval["status"].AsString(true) != "ok") { JSONValue jSONValue = jval["message"]; error = jSONValue.AsString(true); } return(error != null); } catch (JSONParseException jSONParseException1) { JSONParseException jSONParseException = jSONParseException1; error = "Error parsing reply from AssetStore"; DebugUtils.LogError(string.Concat("Error parsing server reply: ", response.data)); DebugUtils.LogError(jSONParseException.Message); flag = true; } return(flag); }
protected override void Parse(Dictionary <string, JSONValue> dict) { this.packageID = int.Parse(dict["package_id"].AsString()); this.message = !dict.ContainsKey("message") ? null : dict["message"].AsString(true); JSONValue value4 = dict["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 "password-missing": this.status = Status.PasswordMissing; break; case "password-wrong": this.status = Status.PasswordWrong; break; case "purchase-declined": this.status = Status.PurchaseDeclined; break; case "ok": this.status = Status.Ok; break; } }
public AssetStoreContext.PackageList GetPackageList() { Dictionary <string, AssetStoreContext.Package> dictionary = new Dictionary <string, AssetStoreContext.Package>(); PackageInfo[] packageList = PackageInfo.GetPackageList(); PackageInfo[] array = packageList; int i = 0; while (i < array.Length) { PackageInfo packageInfo = array[i]; AssetStoreContext.Package package = new AssetStoreContext.Package(); if (packageInfo.jsonInfo == string.Empty) { package.title = Path.GetFileNameWithoutExtension(packageInfo.packagePath); package.id = packageInfo.packagePath; if (this.IsBuiltinStandardAsset(packageInfo.packagePath)) { package.publisher = new AssetStoreContext.LabelAndId { label = "Unity Technologies", id = "1" }; package.category = new AssetStoreContext.LabelAndId { label = "Prefab Packages", id = "4" }; package.version = "3.5.0.0"; } goto IL_144; } JSONValue json = JSONParser.SimpleParse(packageInfo.jsonInfo); if (!json.IsNull()) { package.Initialize(json); if (package.id != null) { goto IL_144; } JSONValue jSONValue = json.Get("link.id"); if (!jSONValue.IsNull()) { package.id = jSONValue.AsString(); goto IL_144; } package.id = packageInfo.packagePath; goto IL_144; } IL_203: i++; continue; IL_144: package.local_icon = packageInfo.iconURL; package.local_path = packageInfo.packagePath; if (!dictionary.ContainsKey(package.id) || dictionary[package.id].version_id == null || dictionary[package.id].version_id == "-1" || (package.version_id != null && package.version_id != "-1" && int.Parse(dictionary[package.id].version_id) <= int.Parse(package.version_id))) { dictionary[package.id] = package; goto IL_203; } goto IL_203; } AssetStoreContext.Package[] results = dictionary.Values.ToArray <AssetStoreContext.Package>(); return(new AssetStoreContext.PackageList { results = results }); }
public AssetStoreContext.PackageList GetPackageList() { Dictionary <string, AssetStoreContext.Package> dictionary = new Dictionary <string, AssetStoreContext.Package>(); foreach (PackageInfo package1 in PackageInfo.GetPackageList()) { AssetStoreContext.Package package2 = new AssetStoreContext.Package(); if (package1.jsonInfo == string.Empty) { package2.title = Path.GetFileNameWithoutExtension(package1.packagePath); package2.id = package1.packagePath; if (this.IsBuiltinStandardAsset(package1.packagePath)) { package2.publisher = new AssetStoreContext.LabelAndId() { label = "Unity Technologies", id = "1" }; package2.category = new AssetStoreContext.LabelAndId() { label = "Prefab Packages", id = "4" }; package2.version = "3.5.0.0"; } } else { JSONValue json = JSONParser.SimpleParse(package1.jsonInfo); if (!json.IsNull()) { package2.Initialize(json); if (package2.id == null) { JSONValue jsonValue = json.Get("link.id"); package2.id = jsonValue.IsNull() ? package1.packagePath : jsonValue.AsString(); } } else { continue; } } package2.local_icon = package1.iconURL; package2.local_path = package1.packagePath; if (!dictionary.ContainsKey(package2.id) || dictionary[package2.id].version_id == null || dictionary[package2.id].version_id == "-1" || package2.version_id != null && package2.version_id != "-1" && int.Parse(dictionary[package2.id].version_id) <= int.Parse(package2.version_id)) { dictionary[package2.id] = package2; } } AssetStoreContext.Package[] array = dictionary.Values.ToArray <AssetStoreContext.Package>(); return(new AssetStoreContext.PackageList() { results = array }); }
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; } } }
private static string OnPackageReceived(JSONValue jval, Package package) { string str; string str1 = "unknown"; try { if (jval.ContainsKey("id")) { string empty = string.Empty; string empty1 = string.Empty; string empty2 = string.Empty; string str2 = string.Empty; string empty3 = string.Empty; bool flag = false; string str3 = string.Empty; string empty4 = string.Empty; string str4 = string.Empty; str1 = "id"; if (!jval[str1].IsNull()) { JSONValue item = jval[str1]; package.versionId = int.Parse(item.AsString(false)); } str1 = "name"; jval.Copy(str1, ref empty, false); str1 = "version_name"; jval.Copy(str1, ref empty1, false); str1 = "root_guid"; jval.Copy(str1, ref empty2, false); str1 = "root_path"; jval.Copy(str1, ref str2, false); str1 = "project_path"; jval.Copy(str1, ref empty3, false); str1 = "is_complete_project"; jval.Copy(str1, ref flag); str1 = "preview_url"; jval.Copy(str1, ref str3); str1 = "icon_url"; jval.Copy(str1, ref empty4); str1 = "status"; jval.Copy(str1, ref str4); package.Name = empty; package.VersionName = empty1; package.RootGUID = empty2; package.RootPath = str2; package.ProjectPath = empty3; package.IsCompleteProjects = flag; package.PreviewURL = str3; package.SetStatus(str4); if (!string.IsNullOrEmpty(empty4)) { package.SetIconURL(empty4); } return(null); } else { str = null; } } catch (JSONTypeException jSONTypeException1) { JSONTypeException jSONTypeException = jSONTypeException1; str = string.Concat(new string[] { "Malformed metadata response for package '", 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); }