Beispiel #1
0
 private void Init()
 {
     this.Account.Reset();
     this.Account.mStatus     = AssetStorePublisher.Status.NotLoaded;
     this.m_PackageDataSource = new PackageDataSource();
     this.m_PackageController = new AssetStorePackageController(this.m_PackageDataSource);
 }
Beispiel #2
0
    public static void GetMetaData(AssetStorePublisher publisherAccount, PackageDataSource packageDataSource, DoneCallback callback)
    {
        Type doneCallbackType;
        var  doneCallback = CreateCallbackDelegate("DoneCallback", callback, out doneCallbackType);

        s_Instance.GetRuntimeType().Invoke("GetMetaData", publisherAccount.GetRuntimeObject().Param(), packageDataSource.GetRuntimeObject().Param(), new Parameter(doneCallback, doneCallbackType));
    }
    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);
     });
 }
Beispiel #5
0
 private void OnEnable()
 {
     this.m_PackageDataSource    = new PackageDataSource();
     this.m_PackageController    = new AssetStorePackageController(this.m_PackageDataSource);
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(AssetStoreClient.Update));
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(AssetStoreClient.Update));
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.PackageControllerUpdatePump));
     Application.runInBackground = true;
 }
Beispiel #6
0
 private void OnEnable()
 {
     this.m_PackageDataSource    = new PackageDataSource();
     this.m_PackageController    = new AssetStorePackageController(this.m_PackageDataSource);
     EditorApplication.update   -= new EditorApplication.CallbackFunction(AssetStoreClient.Update);
     EditorApplication.update   += new EditorApplication.CallbackFunction(AssetStoreClient.Update);
     EditorApplication.update   += new EditorApplication.CallbackFunction(this.PackageControllerUpdatePump);
     Application.runInBackground = true;
     DebugUtils.Log(string.Concat("OnEnable", base.GetType().ToString()));
 }
        public void Save(string a_path, byte[] a_asset)
        {
            m_package.BeginUpdate();

            PackageDataSource packageDataSource = new PackageDataSource(a_asset);

            m_package.Add(packageDataSource, a_path);

            m_package.CommitUpdate();
        }
Beispiel #8
0
    private static void OnPackages(JSONValue jv, PackageDataSource packageDataSource)
    {
        IList <Package> allPackages         = packageDataSource.GetAllPackages();
        Dictionary <string, JSONValue> strs = jv.AsDict(false);
        string empty = string.Empty;

        allPackages.Clear();
        foreach (KeyValuePair <string, JSONValue> keyValuePair in strs)
        {
            int       num     = int.Parse(keyValuePair.Key);
            JSONValue value   = keyValuePair.Value;
            Package   package = packageDataSource.FindByID(num) ?? new Package(num);
            empty = string.Concat(empty, AssetStoreAPI.OnPackageReceived(value, package));
            empty = string.Concat(empty, AssetStoreAPI.RefreshMainAssets(value, package));
            allPackages.Add(package);
        }

        packageDataSource.OnDataReceived(empty);
    }
    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> current in dictionary)
        {
            int       num     = int.Parse(current.Key);
            JSONValue value   = current.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);
    }
Beispiel #10
0
    public static void GetMetaData(AssetStorePublisher account, PackageDataSource packageDataSource, AssetStoreAPI.DoneCallback callback)
    {
        AssetStoreClient.CreatePendingGet("metadata", "/metadata/0", (AssetStoreResponse res) =>
        {
            string str;
            JSONValue jSONValue;
            DebugUtils.Log(res.data);
            if (AssetStoreAPI.Parse(res, out str, out jSONValue) && !jSONValue.ContainsKey("error_fields"))
            {
                callback(str);
                return;
            }

            string str1 = "none";
            try
            {
                str1        = "account";
                string str2 = AssetStoreAPI.OnAssetStorePublisher(jSONValue, account, packageDataSource);
                if (str2 != null)
                {
                    callback(str2);
                    return;
                }
            }
            catch (JSONTypeException jSONTypeException)
            {
                callback(string.Concat("Malformed metadata response from server: ", str1, " - ", jSONTypeException.Message));
            }
            catch (KeyNotFoundException keyNotFoundException)
            {
                callback(string.Concat("Malformed metadata response from server. ", str1, " - ", keyNotFoundException.Message));
            }

            callback(null);
        });
    }
Beispiel #11
0
 internal AssetStorePackageController(PackageDataSource packageDataSource)
 {
     this.m_PkgSelectionCtrl = new PackageSelector(packageDataSource, new ListView <Package> .SelectionCallback(this.OnPackageSelected));
     this.ClearLocalState();
 }
Beispiel #12
0
    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)
        {
            string result = "Malformed response from server: " + str + " - " + ex.Message;
            return(result);
        }
        catch (KeyNotFoundException ex2)
        {
            string result = "Malformed response from server. " + str + " - " + ex2.Message;
            return(result);
        }
        return(null);
    }
Beispiel #13
0
    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);
    }