예제 #1
0
    public static StoreKitDownload downloadFromDictionary(Dictionary <string, object> dict)
    {
        var download = new StoreKitDownload();

        if (dict.ContainsKey("downloadState"))
        {
            download.downloadState = (StoreKitDownloadState)int.Parse(dict["downloadState"].ToString());
        }

        if (dict.ContainsKey("contentLength"))
        {
            download.contentLength = double.Parse(dict["contentLength"].ToString());
        }

        if (dict.ContainsKey("contentIdentifier"))
        {
            download.contentIdentifier = dict["contentIdentifier"].ToString();
        }

        if (dict.ContainsKey("contentURL"))
        {
            download.contentURL = dict["contentURL"].ToString();
        }

        if (dict.ContainsKey("contentVersion"))
        {
            download.contentVersion = dict["contentVersion"].ToString();
        }

        if (dict.ContainsKey("error"))
        {
            download.error = dict["error"].ToString();
        }

        if (dict.ContainsKey("progress"))
        {
            download.progress = float.Parse(dict["progress"].ToString());
        }

        if (dict.ContainsKey("timeRemaining"))
        {
            download.timeRemaining = double.Parse(dict["timeRemaining"].ToString());
        }

        if (dict.ContainsKey("transaction"))
        {
            download.transaction = StoreKitTransaction.transactionFromDictionary(dict["transaction"] as Dictionary <string, object>);
        }

        return(download);
    }