コード例 #1
0
ファイル: Downloader.cs プロジェクト: weeble/ohos
 public void NotifyDownloadProgress(string aUrl, int aBytes, int aTotalBytes)
 {
     if (!iDownloads.ContainsKey(aUrl))
     {
         return;
     }
     lock (iPublicDownloadsLock)
     {
         iPublicDownloadInfo[aUrl] = new DownloadProgress(aUrl, aBytes, aTotalBytes, false);
     }
 }
コード例 #2
0
ファイル: AppManager.cs プロジェクト: weeble/ohos
 XElement DownloadProgressToXElement(DownloadProgress aDownload)
 {
     XElement appHandleElement = null;
     XElement appIdElement = null;
     string appName;
     if (iUpgradeAppNamesToUrls.Backward.TryGetValue(aDownload.Uri, out appName))
     {
         uint appHandle = iApps.GetIdForKey(appName);
         appHandleElement = new XElement("appHandle", appHandle);
         appIdElement = new XElement("appId", appName);
     }
     XElement element = new XElement("download",
         new XElement("status", aDownload.HasFailed ? "failed" : "downloading"),
         appHandleElement,
         appIdElement,
         new XElement("url", aDownload.Uri),
         new XElement("progressBytes", aDownload.DownloadedBytes));
     if (aDownload.HasTotalBytes)
     {
         element.Add(
             new XElement("totalBytes", aDownload.TotalBytes),
             new XElement("progressPercent", (int)Math.Round(100.0 * aDownload.DownloadedBytes / aDownload.TotalBytes)));
     }
     return element;
 }