Exemple #1
0
        public PackageSelector(PackageDataSource pkgDataSource, ListView <Package> .SelectionCallback selectionCallback)
        {
            this.m_PkgDataSource = pkgDataSource;
            PackageListGUI gui = new PackageListGUI();

            this.m_PackageList = new ListView <Package>(this.m_PkgDataSource, gui, selectionCallback, selectionCallback);
        }
 public static void GetMetaData(AssetStorePublisher account, PackageDataSource packageDataSource, AssetStoreAPI.DoneCallback callback)
 {
     AssetStoreClient.CreatePendingGet("metadata", "/metadata/0", delegate(AssetStoreResponse res)
     {
         DebugUtils.Log(res.data);
         string errorMessage;
         JSONValue jval;
         bool flag = AssetStoreAPI.Parse(res, out errorMessage, out jval);
         if (flag && !jval.ContainsKey("error_fields"))
         {
             callback(errorMessage);
             return;
         }
         string str = "none";
         try
         {
             str         = "account";
             string text = AssetStoreAPI.OnAssetStorePublisher(jval, account, packageDataSource);
             if (text != null)
             {
                 callback(text);
                 return;
             }
         }
         catch (JSONTypeException ex)
         {
             callback("Malformed metadata response from server: " + str + " - " + ex.Message);
         }
         catch (KeyNotFoundException ex2)
         {
             callback("Malformed metadata response from server. " + str + " - " + ex2.Message);
         }
         callback(null);
     });
 }
        private static void OnPackages(JSONValue jv, PackageDataSource packageDataSource)
        {
            IList <Package> allPackages = packageDataSource.GetAllPackages();
            Dictionary <string, JSONValue> dictionary = jv.AsDict(false);
            string text = string.Empty;

            foreach (KeyValuePair <string, JSONValue> keyValuePair in dictionary)
            {
                int       num     = int.Parse(keyValuePair.Key);
                JSONValue value   = keyValuePair.Value;
                Package   package = packageDataSource.FindByID(num);
                if (package == null)
                {
                    package = new Package(num);
                }
                text += AssetStoreAPI.OnPackageReceived(value, package);
                text += AssetStoreAPI.RefreshMainAssets(value, package);
                allPackages.Add(package);
            }
            packageDataSource.OnDataReceived(text);
        }
 internal AssetStorePackageController(PackageDataSource packageDataSource)
 {
     this.m_PkgSelectionCtrl = new PackageSelector(packageDataSource, new ListView <Package> .SelectionCallback(this.OnPackageSelected));
     this.ClearLocalState();
 }
        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);
        }