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 jsonvalue2 in list2)
                    {
                        list.Add(jsonvalue2.AsString(false));
                    }
                    package.MainAssets = list;
                }
            }
            catch (JSONTypeException ex)
            {
                return(string.Concat(new string[]
                {
                    "Malformed metadata response for mainAssets '",
                    package.Name,
                    "' field '",
                    text,
                    "': ",
                    ex.Message
                }));
            }
            catch (KeyNotFoundException ex2)
            {
                return(string.Concat(new string[]
                {
                    "Malformed metadata response for package. '",
                    package.Name,
                    "' field '",
                    text,
                    "': ",
                    ex2.Message
                }));
            }
            return(null);
        }
        private static string OnAssetStorePublisher(JSONValue jval, AssetStorePublisher account, PackageDataSource packageDataSource)
        {
            string str = "unknown field";

            try
            {
                str = "publisher";
                Dictionary <string, JSONValue> dictionary = jval["publisher"].AsDict(false);
                account.mStatus = AssetStorePublisher.Status.New;
                if (dictionary.ContainsKey("name"))
                {
                    account.mStatus       = AssetStorePublisher.Status.Existing;
                    str                   = "publisher -> id";
                    account.publisherId   = int.Parse(dictionary["id"].AsString(false));
                    str                   = "publisher -> name";
                    account.publisherName = dictionary["name"].AsString(false);
                }
                str = "publisher";
                if (AssetStoreManager.sDbg)
                {
                    DebugUtils.Log("publisher " + jval["publisher"].ToString(string.Empty, "    "));
                    DebugUtils.Log("packs " + jval["packages"].ToString(string.Empty, "    "));
                }
                str = "packages";
                if (!jval.Get("packages").IsNull())
                {
                    AssetStoreAPI.OnPackages(jval["packages"], packageDataSource);
                }
            }
            catch (JSONTypeException ex)
            {
                return("Malformed response from server: " + str + " - " + ex.Message);
            }
            catch (KeyNotFoundException ex2)
            {
                return("Malformed response from server. " + str + " - " + ex2.Message);
            }
            return(null);
        }
 private static AssetStoreClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback)
 {
     return(delegate(AssetStoreResponse resp)
     {
         AssetStoreClient.UserIconUrl = null;
         int num = -1;
         if (resp.HttpHeaders != null)
         {
             num = Array.IndexOf <string>(resp.HttpHeaders.AllKeys, "X-Unity-Reason");
         }
         if (!resp.ok)
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed communication" : resp.HttpHeaders.Get(num));
             DebugUtils.LogError(resp.HttpErrorMessage ?? "Unknown http error");
         }
         else if (resp.data.StartsWith("<!DOCTYPE"))
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed to login" : resp.HttpHeaders.Get(num));
             DebugUtils.LogError(resp.data ?? "no data");
         }
         else
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN;
             JSONValue jsonvalue = JSONParser.SimpleParse(resp.data);
             AssetStoreClient.ActiveSessionID = jsonvalue["xunitysession"].AsString(false);
             AssetStoreClient.UserIconUrl = jsonvalue.Get("keyimage.icon").AsString(false);
             if (AssetStoreClient.RememberSession)
             {
                 AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID;
             }
         }
         callback(AssetStoreClient.sLoginErrorMessage);
     });
 }