public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback) { string[] dest = PackageStorePath(publisher_name, category_name, package_name, package_id, url); JSONValue existing = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, dest, key)); // If the package is actively being downloaded right now just return if (existing.Get("in_progress").AsBool(true)) { Debug.Log("Will not download " + package_name + ". Download is already in progress."); return; } // The package is not being downloaded. // If the package has previously been partially downloaded then // resume that download. string existingUrl = existing.Get("download.url").AsString(true); string existingKey = existing.Get("download.key").AsString(true); bool resumeOK = (existingUrl == url && existingKey == key); JSONValue download = new JSONValue(); download["url"] = url; download["key"] = key; JSONValue parameters = new JSONValue(); parameters["download"] = download; AssetStoreUtils.Download(package_id, url, dest, key, parameters.ToString(), resumeOK, doneCallback); }
public string ToString(string curIndent, string indent) { bool flag = curIndent != null; if (this.IsString()) { return(string.Concat("\"", JSONValue.EncodeString(this.AsString(false)), "\"")); } if (this.IsFloat()) { return(this.AsFloat(false).ToString()); } if (this.IsList()) { string str = "["; string empty = string.Empty; foreach (JSONValue jSONValue in this.AsList(false)) { str = string.Concat(str, empty, jSONValue.ToString()); empty = ", "; } return(string.Concat(str, "]")); } if (!this.IsDict()) { if (this.IsBool()) { return(!this.AsBool(false) ? "false" : "true"); } if (!this.IsNull()) { throw new JSONTypeException("Cannot serialize json value of unknown type"); } return("null"); } string str1 = string.Concat("{", (!flag ? string.Empty : "\n")); string empty1 = string.Empty; foreach (KeyValuePair <string, JSONValue> keyValuePair in this.AsDict(false)) { string str2 = str1; object[] objArray = new object[] { str2, empty1, curIndent, indent, '\"', JSONValue.EncodeString(keyValuePair.Key), "\" : ", null }; JSONValue value = keyValuePair.Value; objArray[7] = value.ToString(string.Concat(curIndent, indent), indent); str1 = string.Concat(objArray); empty1 = string.Concat(", ", (!flag ? string.Empty : "\n")); } return(string.Concat(str1, (!flag ? string.Empty : string.Concat("\n", curIndent)), "}")); }
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 static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback) { string[] destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url); JSONValue jSONValue = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key)); if (jSONValue.Get("in_progress").AsBool(true)) { Debug.Log("Will not download " + package_name + ". Download is already in progress."); return; } string a = jSONValue.Get("download.url").AsString(true); string a2 = jSONValue.Get("download.key").AsString(true); bool resumeOK = a == url && a2 == key; JSONValue value = default(JSONValue); value["url"] = url; value["key"] = key; JSONValue jSONValue2 = default(JSONValue); jSONValue2["download"] = value; AssetStoreUtils.Download(package_id, url, destination, key, jSONValue2.ToString(), resumeOK, doneCallback); }
public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback) { string[] destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url); JSONValue jsonValue1 = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key)); if (jsonValue1.Get("in_progress").AsBool(true)) { Debug.Log((object)("Will not download " + package_name + ". Download is already in progress.")); } else { string str1 = jsonValue1.Get("download.url").AsString(true); string str2 = jsonValue1.Get("download.key").AsString(true); bool resumeOK = str1 == url && str2 == key; JSONValue jsonValue2 = new JSONValue(); jsonValue2["url"] = (JSONValue)url; jsonValue2["key"] = (JSONValue)key; JSONValue jsonValue3 = new JSONValue(); jsonValue3["download"] = jsonValue2; AssetStoreUtils.Download(package_id, url, destination, key, jsonValue3.ToString(), resumeOK, doneCallback); } }
public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback) { string[] destination = PackageStorePath(publisher_name, category_name, package_name, package_id, url); JSONValue value2 = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key)); if (value2.Get("in_progress").AsBool(true)) { Debug.Log("Will not download " + package_name + ". Download is already in progress."); } else { string str = value2.Get("download.url").AsString(true); string str2 = value2.Get("download.key").AsString(true); bool resumeOK = (str == url) && (str2 == key); JSONValue value3 = new JSONValue(); value3["url"] = url; value3["key"] = key; JSONValue value4 = new JSONValue(); value4["download"] = value3; AssetStoreUtils.Download(package_id, url, destination, key, value4.ToString(), resumeOK, doneCallback); } }