예제 #1
0
        private void OnDownloadUpdate(object sender, DownloadUpdateEventArgs e)
        {
            UpdateInfo updateInfo = e.UserData as UpdateInfo;

            if (updateInfo == null)
            {
                return;
            }

            if (m_DownloadComponent == null)
            {
                throw new Exception("You must set download manager first.");
            }

            if (e.CurrentLength > updateInfo.ZipLength)
            {
                m_DownloadComponent.RemoveDownload(e.SerialId);
                string downloadFile = Utility.Text.Format("{0}.download", e.DownloadPath);
                if (File.Exists(downloadFile))
                {
                    File.Delete(downloadFile);
                }

                string errorMessage = Utility.Text.Format("When download update, downloaded length is larger than zip length, need '{0}', downloaded '{1}'.", updateInfo.ZipLength.ToString(), e.CurrentLength.ToString());
                DownloadFailureEventArgs downloadFailureEventArgs = DownloadFailureEventArgs.Create(e.SerialId, e.DownloadPath, e.DownloadUri, errorMessage, e.UserData);
                OnDownloadFailure(this, downloadFailureEventArgs);
                ReferencePool.Release(downloadFailureEventArgs);
                return;
            }

            m_ResourceComponent.OnUpdaterResourceUpdateChanged(updateInfo.ResourceName, e.DownloadPath, e.DownloadUri, e.CurrentLength, updateInfo.ZipLength);
        }
예제 #2
0
 /// <summary>
 /// 移除下载任务。
 /// </summary>
 /// <param name="serialId">要移除下载任务的序列编号。</param>
 public void RemoveDownload(int serialId)
 {
     m_DownloadComponent.RemoveDownload(serialId);
 }