예제 #1
0
 public override string ToString()
 {
     if (this.IsString())
     {
         return("\"" + JSONValue.EncodeString(this.AsString()) + "\"");
     }
     if (this.IsFloat())
     {
         return(this.AsFloat().ToString());
     }
     if (this.IsList())
     {
         string str1 = "[";
         string str2 = string.Empty;
         using (List <JSONValue> .Enumerator enumerator = this.AsList().GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 JSONValue current = enumerator.Current;
                 str1 = str1 + str2 + current.ToString();
                 str2 = ", ";
             }
         }
         return(str1 + "]");
     }
     if (this.IsDict())
     {
         string str1 = "{";
         string str2 = string.Empty;
         using (Dictionary <string, JSONValue> .Enumerator enumerator = this.AsDict().GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 KeyValuePair <string, JSONValue> current = enumerator.Current;
                 str1 = str1 + str2 + (object)'"' + JSONValue.EncodeString(current.Key) + "\" : " + current.Value.ToString();
                 str2 = ", ";
             }
         }
         return(str1 + "}");
     }
     if (this.IsBool())
     {
         return(this.AsBool() ? "true" : "false");
     }
     if (this.IsNull())
     {
         return("null");
     }
     throw new JSONTypeException("Cannot serialize json value of unknown type");
 }
예제 #2
0
 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);
     }
 }
 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);
   }
 }