private static bool Parse(AssetStoreResponse response, out string error, out JSONValue jval) { jval = default(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 { JSONParser jSONParser = new JSONParser(response.data); jval = jSONParser.Parse(); } catch (JSONParseException ex) { error = "Error parsing reply from AssetStore"; DebugUtils.LogError("Error parsing server reply: " + response.data); DebugUtils.LogError(ex.Message); return(true); } if (jval.ContainsKey("error")) { error = jval["error"].AsString(true); } else if (jval.ContainsKey("status") && jval["status"].AsString(true) != "ok") { error = jval["message"].AsString(true); } return(error != null); }
public void Initialize(JSONValue json) { if (json.ContainsKey("label")) { this.label = json["label"].AsString(); } if (json.ContainsKey("id")) { this.id = json["id"].AsString(); } }
public void Initialize(JSONValue json) { if (json.ContainsKey("type")) { this.type = json["type"].AsString(); } if (json.ContainsKey("id")) { this.id = json["id"].AsString(); } }
protected override JSONValue HandlePost(Request request, JSONValue payload) { ScriptEditorSettings.ServerURL = payload["url"].AsString(); ScriptEditorSettings.Name = !payload.ContainsKey("name") ? (string)null : payload["name"].AsString(); ScriptEditorSettings.ProcessId = !payload.ContainsKey("processid") ? -1 : (int)payload["processid"].AsFloat(); Logger.Log("[Pair] Name: " + (ScriptEditorSettings.Name ?? "<null>") + " ServerURL " + ScriptEditorSettings.ServerURL + " Process id: " + (object)ScriptEditorSettings.ProcessId); JSONValue jsonValue = new JSONValue(); jsonValue["unityprocessid"] = (JSONValue)Process.GetCurrentProcess().Id; jsonValue["unityproject"] = (JSONValue)Application.dataPath; return(jsonValue); }
public JSONValue Get(string key, out bool found) { found = false; if (!this.IsDict()) { return(new JSONValue(null)); } JSONValue result = this; string[] array = key.Split(new char[] { '.' }); for (int i = 0; i < array.Length; i++) { string index = array[i]; if (!result.ContainsKey(index)) { return(new JSONValue(null)); } result = result[index]; } found = true; return(result); }
protected override JSONValue HandlePost(Request request, JSONValue payload) { ScriptEditorSettings.ServerURL = payload["url"].AsString(); ScriptEditorSettings.Name = payload.ContainsKey("name") ? payload["name"].AsString() : null; ScriptEditorSettings.ProcessId = payload.ContainsKey("processid") ? (int)payload["processid"].AsFloat() : -1; Logger.Log("[Pair] Name: " + (ScriptEditorSettings.Name ?? "<null>") + " ServerURL " + ScriptEditorSettings.ServerURL + " Process id: " + ScriptEditorSettings.ProcessId); var result = new JSONValue(); result["unityprocessid"] = Process.GetCurrentProcess().Id; result["unityproject"] = Application.dataPath; return(result); }
public JSONValue Get(string key, out bool found) { found = false; if (!this.IsDict()) { return(new JSONValue(null)); } JSONValue item = this; string[] strArrays = key.Split(new char[] { '.' }); for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; if (!item.ContainsKey(str)) { return(new JSONValue(null)); } item = item[str]; } found = true; return(item); }
protected override JSONValue HandlePost(Request request, JSONValue payload) { ScriptEditorSettings.OpenDocuments = payload.ContainsKey("documents") ? payload["documents"].AsList().Select(d => d.AsString()).ToList() : new List <string>(); ScriptEditorSettings.Save(); return(new JSONValue()); }
string ReadJsonString(JSONValue json, string key) { if (json.ContainsKey(key) && !json[key].IsNull()) { return(json[key].AsString()); } return(null); }
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); } } } }
protected override JSONValue HandlePost(Request request, JSONValue payload) { ScriptEditorSettings.ServerURL = payload["url"].AsString(); ScriptEditorSettings.Name = ((!payload.ContainsKey("name")) ? null : payload["name"].AsString()); ScriptEditorSettings.ProcessId = ((!payload.ContainsKey("processid")) ? -1 : ((int)payload["processid"].AsFloat())); Logger.Log(string.Concat(new object[] { "[Pair] Name: ", ScriptEditorSettings.Name ?? "<null>", " ServerURL ", ScriptEditorSettings.ServerURL, " Process id: ", ScriptEditorSettings.ProcessId })); JSONValue result = default(JSONValue); result["unityprocessid"] = Process.GetCurrentProcess().Id; result["unityproject"] = Application.dataPath; return(result); }
protected override JSONValue HandlePost(Request request, JSONValue payload) { JSONValue value2; if (payload.ContainsKey("documents")) { value2 = payload["documents"]; } ScriptEditorSettings.OpenDocuments = (< > f__am$cache0 != null) ? new List <string>() : Enumerable.Select <JSONValue, string>(value2.AsList(), <> f__am$cache0).ToList <string>(); ScriptEditorSettings.Save(); return(new JSONValue()); }
public static string GetUsymUploadAuthToken() { string token = string.Empty; var originalCallback = ServicePointManager.ServerCertificateValidationCallback; try { string environmentValue = Environment.GetEnvironmentVariable("USYM_UPLOAD_AUTH_TOKEN"); if (!string.IsNullOrEmpty(environmentValue)) { return(environmentValue); } CrashReportingSettings.EnsureConnectReady(); string accessToken = UnityConnect.instance.GetAccessToken(); if (string.IsNullOrEmpty(accessToken)) { return(string.Empty); } // Only OSX supports SSL certificate validation, disable checking on other platforms. // Fix when a Unity Web framework supports SSL. if (Application.platform != RuntimePlatform.OSXEditor) { ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true; } WebRequest request = WebRequest.Create(ServiceTokenUrl); request.Timeout = 15000; // 15 Seconds request.Headers.Add("Authorization", string.Format("Bearer {0}", accessToken)); HttpWebResponse response = request.GetResponse() as HttpWebResponse; string tokenJson = string.Empty; using (StreamReader sr = new StreamReader(response.GetResponseStream())) { tokenJson = sr.ReadToEnd(); } JSONValue parsedJson = JSONParser.SimpleParse(tokenJson); if (parsedJson.ContainsKey("AuthToken")) { token = parsedJson["AuthToken"].AsString(); } } catch (Exception ex) { Debug.LogWarningFormat("Exception occurred attempting to connect to Unity Cloud Diagnostics service. Native symbols will not be uploaded for this build. Exception details:\n{0}\n{1}", ex.ToString(), ex.StackTrace); } ServicePointManager.ServerCertificateValidationCallback = originalCallback; return(token); }
protected override JSONValue HandlePost(Request request, JSONValue payload) { ScriptEditorSettings.ServerURL = payload["url"].AsString(); ScriptEditorSettings.Name = !payload.ContainsKey("name") ? null : payload["name"].AsString(); ScriptEditorSettings.ProcessId = !payload.ContainsKey("processid") ? -1 : ((int)payload["processid"].AsFloat()); object[] objArray1 = new object[6]; objArray1[0] = "[Pair] Name: "; if (ScriptEditorSettings.Name == null) { } objArray1[1] = "<null>"; objArray1[2] = " ServerURL "; objArray1[3] = ScriptEditorSettings.ServerURL; objArray1[4] = " Process id: "; objArray1[5] = ScriptEditorSettings.ProcessId; UnityEditor.RestService.Logger.Log(string.Concat(objArray1)); return(new JSONValue { ["unityprocessid"] = Process.GetCurrentProcess().Id, ["unityproject"] = Application.dataPath }); }
private void ParseList(JSONValue matches, ref Group group) { List <AssetStoreAsset> assets = group.assets; if (matches.ContainsKey("error")) { error = matches["error"].AsString(true); } if (matches.ContainsKey("warnings")) { 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; // fallback if (matches.ContainsKey("total_found")) { group.totalFound = (int)matches["total_found"].AsFloat(true); } if (matches.ContainsKey("matches")) { foreach (JSONValue asset in matches["matches"].AsList(true)) { AssetStoreAsset res = new AssetStoreAsset(); if (!asset.ContainsKey("id") || !asset.ContainsKey("name") || !asset.ContainsKey("package_id")) { continue; } res.id = (int)asset["id"].AsFloat(); res.name = asset["name"].AsString(); res.displayName = StripExtension(res.name); res.packageID = (int)asset["package_id"].AsFloat(); if (asset.ContainsKey("static_preview_url")) { res.staticPreviewURL = asset["static_preview_url"].AsString(); } if (asset.ContainsKey("dynamic_preview_url")) { res.dynamicPreviewURL = asset["dynamic_preview_url"].AsString(); } res.className = asset.ContainsKey("class_name") ? asset["class_name"].AsString() : ""; if (asset.ContainsKey("price")) { res.price = asset["price"].AsString(); } assets.Add(res); } } }
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); }
public static string GetUsymUploadAuthToken() { string text = string.Empty; RemoteCertificateValidationCallback serverCertificateValidationCallback = ServicePointManager.ServerCertificateValidationCallback; string result; try { string environmentVariable = Environment.GetEnvironmentVariable("USYM_UPLOAD_AUTH_TOKEN"); if (!string.IsNullOrEmpty(environmentVariable)) { result = environmentVariable; return(result); } string accessToken = UnityConnect.instance.GetAccessToken(); if (string.IsNullOrEmpty(accessToken)) { result = string.Empty; return(result); } if (Application.platform != RuntimePlatform.OSXEditor) { ServicePointManager.ServerCertificateValidationCallback = ((object a, X509Certificate b, X509Chain c, SslPolicyErrors d) => true); } WebRequest webRequest = WebRequest.Create(CrashReporting.ServiceTokenUrl); webRequest.Timeout = 15000; webRequest.Headers.Add("Authorization", string.Format("Bearer {0}", accessToken)); HttpWebResponse httpWebResponse = webRequest.GetResponse() as HttpWebResponse; string jsondata = string.Empty; using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream())) { jsondata = streamReader.ReadToEnd(); } JSONValue jSONValue = JSONParser.SimpleParse(jsondata); if (jSONValue.ContainsKey("AuthToken")) { text = jSONValue["AuthToken"].AsString(); } } catch (Exception exception) { UnityEngine.Debug.LogException(exception); } ServicePointManager.ServerCertificateValidationCallback = serverCertificateValidationCallback; result = text; return(result); }
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 JSONValue HandlePost(Request request, JSONValue payload) { List <string> arg_57_0; if (payload.ContainsKey("documents")) { arg_57_0 = (from d in payload["documents"].AsList() select d.AsString()).ToList <string>(); } else { arg_57_0 = new List <string>(); } ScriptEditorSettings.OpenDocuments = arg_57_0; ScriptEditorSettings.Save(); return(default(JSONValue)); }
public void Initialize(JSONValue json) { if (json.ContainsKey("title")) { this.title = json["title"].AsString(); } if (json.ContainsKey("id")) { this.id = json["id"].AsString(); } if (json.ContainsKey("version")) { this.version = json["version"].AsString(); } if (json.ContainsKey("version_id")) { this.version_id = json["version_id"].AsString(); } if (json.ContainsKey("local_icon")) { this.local_icon = json["local_icon"].AsString(); } if (json.ContainsKey("local_path")) { this.local_path = json["local_path"].AsString(); } if (json.ContainsKey("pubdate")) { this.pubdate = json["pubdate"].AsString(); } if (json.ContainsKey("description")) { this.description = json["description"].AsString(); } if (json.ContainsKey("publisher")) { this.publisher = new AssetStoreContext.LabelAndId(); this.publisher.Initialize(json["publisher"]); } if (json.ContainsKey("category")) { this.category = new AssetStoreContext.LabelAndId(); this.category.Initialize(json["category"]); } if (json.ContainsKey("link")) { this.link = new AssetStoreContext.Link(); this.link.Initialize(json["link"]); } }
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); }
public void Initialize(JSONValue json) { if (json.ContainsKey("title")) { title = json["title"].AsString(); } if (json.ContainsKey("id")) { id = json["id"].AsString(); } if (json.ContainsKey("version")) { version = json["version"].AsString(); } if (json.ContainsKey("version_id")) { version_id = json["version_id"].AsString(); } if (json.ContainsKey("local_icon")) { local_icon = json["local_icon"].AsString(); } if (json.ContainsKey("local_path")) { local_path = json["local_path"].AsString(); } if (json.ContainsKey("pubdate")) { pubdate = json["pubdate"].AsString(); } if (json.ContainsKey("description")) { description = json["description"].AsString(); } if (json.ContainsKey("publisher")) { publisher = new LabelAndId(); publisher.Initialize(json["publisher"]); } if (json.ContainsKey("category")) { category = new LabelAndId(); category.Initialize(json["category"]); } if (json.ContainsKey("link")) { link = new Link(); link.Initialize(json["link"]); } }
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); } } } }
private static string OnPackageReceived(JSONValue jval, Package package) { string text = "unknown"; try { if (!jval.ContainsKey("id")) { string result = null; return(result); } string empty = string.Empty; string empty2 = string.Empty; string empty3 = string.Empty; string empty4 = string.Empty; string empty5 = string.Empty; bool isCompleteProjects = false; string empty6 = string.Empty; string empty7 = string.Empty; string empty8 = string.Empty; text = "id"; if (!jval[text].IsNull()) { package.versionId = int.Parse(jval[text].AsString(false)); } text = "name"; jval.Copy(text, ref empty, false); text = "version_name"; jval.Copy(text, ref empty2, false); text = "root_guid"; jval.Copy(text, ref empty3, false); text = "root_path"; jval.Copy(text, ref empty4, false); text = "project_path"; jval.Copy(text, ref empty5, false); text = "is_complete_project"; jval.Copy(text, ref isCompleteProjects); text = "preview_url"; jval.Copy(text, ref empty6); text = "icon_url"; jval.Copy(text, ref empty7); text = "status"; jval.Copy(text, ref empty8); package.Name = empty; package.VersionName = empty2; package.RootGUID = empty3; package.RootPath = empty4; package.ProjectPath = empty5; package.IsCompleteProjects = isCompleteProjects; package.PreviewURL = empty6; package.SetStatus(empty8); if (!string.IsNullOrEmpty(empty7)) { package.SetIconURL(empty7); } } catch (JSONTypeException ex) { string result = string.Concat(new string[] { "Malformed metadata response for package '", 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) { Dictionary <string, JSONValue> dictionary = dict["purchase_info"].AsDict(true); string str = dictionary["status"].AsString(true); if (str == "basket-not-empty") { this.status = AssetStoreAssetsInfo.Status.BasketNotEmpty; } else if (str == "service-disabled") { this.status = AssetStoreAssetsInfo.Status.ServiceDisabled; } else if (str == "user-anonymous") { this.status = AssetStoreAssetsInfo.Status.AnonymousUser; } else if (str == "ok") { this.status = AssetStoreAssetsInfo.Status.Ok; } 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") ? (string)null : dictionary["message"].AsString(true); using (List <JSONValue> .Enumerator enumerator = dict["results"].AsList(true).GetEnumerator()) { while (enumerator.MoveNext()) { JSONValue current = enumerator.Current; AssetStoreAsset assetStoreAsset; if (this.assets.TryGetValue(!current["id"].IsString() ? (int)current["id"].AsFloat() : int.Parse(current["id"].AsString()), out assetStoreAsset)) { if (assetStoreAsset.previewInfo == null) { assetStoreAsset.previewInfo = new AssetStoreAsset.PreviewInfo(); } AssetStoreAsset.PreviewInfo previewInfo = assetStoreAsset.previewInfo; assetStoreAsset.className = current["class_names"].AsString(true).Trim(); previewInfo.packageName = current["package_name"].AsString(true).Trim(); previewInfo.packageShortUrl = current["short_url"].AsString(true).Trim(); assetStoreAsset.price = !current.ContainsKey("price_text") ? (string)null : current["price_text"].AsString(true).Trim(); previewInfo.packageSize = int.Parse(!current.Get("package_size").IsNull() ? current["package_size"].AsString(true) : "-1"); assetStoreAsset.packageID = int.Parse(current["package_id"].AsString()); previewInfo.packageVersion = current["package_version"].AsString(); previewInfo.packageRating = int.Parse(current.Get("rating").IsNull() || current["rating"].AsString(true).Length == 0 ? "-1" : current["rating"].AsString(true)); previewInfo.packageAssetCount = int.Parse(!current["package_asset_count"].IsNull() ? current["package_asset_count"].AsString(true) : "-1"); previewInfo.isPurchased = current.ContainsKey("purchased") && current["purchased"].AsBool(true); previewInfo.isDownloadable = previewInfo.isPurchased || assetStoreAsset.price == null; previewInfo.publisherName = current["publisher_name"].AsString(true).Trim(); previewInfo.packageUrl = !current.Get("package_url").IsNull() ? current["package_url"].AsString(true) : string.Empty; previewInfo.encryptionKey = !current.Get("encryption_key").IsNull() ? current["encryption_key"].AsString(true) : string.Empty; previewInfo.categoryName = !current.Get("category_name").IsNull() ? current["category_name"].AsString(true) : string.Empty; previewInfo.buildProgress = -1f; previewInfo.downloadProgress = -1f; } } } }