コード例 #1
0
        internal DownloadJob(Guid id, IBackgroundCopyJob bitsJob)
        {
            this.id = id;

            string name;

            bitsJob.GetDisplayName(out name);
            DisplayName = name;

            string description;

            bitsJob.GetDescription(out description);
            Description = description;

            BG_JOB_PRIORITY priority;

            bitsJob.GetPriority(out priority);
            Priority = (DownloadPriority)(int)priority;

            bitsJob.GetMinimumRetryDelay(out minimumRetryDelay);
            bitsJob.GetNoProgressTimeout(out noProgressTimeout);

            BG_JOB_STATE state;

            bitsJob.GetState(out state);
            Status = (DownloadStatus)(int)state;

            _BG_JOB_PROGRESS progress;

            bitsJob.GetProgress(out progress);
            BytesTotal       = progress.BytesTotal;
            BytesTransferred = progress.BytesTransferred;

            bitsJob.SetNotifyInterface(this);

            IEnumBackgroundCopyFiles enumFiles = null;

            try {
                bitsJob.EnumFiles(out enumFiles);
                uint fetched;
                IBackgroundCopyFile file;
                enumFiles.Next(1, out file, out fetched);
                if (fetched == 1)
                {
                    string remoteUrl;
                    file.GetRemoteName(out remoteUrl);
                    RemoteUrl = remoteUrl;

                    string localName;
                    file.GetLocalName(out localName);
                    LocalFile = localName;
                }
            } finally {
                if (enumFiles != null)
                {
                    Marshal.ReleaseComObject(enumFiles);
                }
            }
        }
コード例 #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             //TODO: release COM resource
             this.fileList = null;
         }
     }
     disposed = true;
 }
コード例 #3
0
 public BitsFiles EnumFiles()
 {
     try
     {
         IEnumBackgroundCopyFiles fileList = null;
         this.job.EnumFiles(out fileList);
         this.files = new BitsFiles(this, fileList);
     }
     catch (COMException exception)
     {
         manager.PublishException(this, exception);
     }
     return(this.files);
 }
コード例 #4
0
 public MsBitsFiles(IEnumBackgroundCopyFiles files)
     : base(() => files.Reset(),
            () =>
 {
     IBackgroundCopyFile file = null;
     uint fetched             = 0;
     files.Next(1, out file, out fetched);
     return(fetched == 1 ? file : null);
 },
            () =>
 {
     uint count;
     files.GetCount(out count);
     return((int)count);
 })
 {
 }
コード例 #5
0
        /// <summary>Releases unmanaged and - optionally - managed resources.</summary>
        /// <param name="disposing"><c>True</c> to release both managed and unmanaged resources; otherwise, <c>False</c> to release only unmanaged resources.</param>
        void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    // TODO: release COM resource
                    this.fileList = null;
                    if (this.job != null)
                    {
                        this.job.Dispose();
                    }
                }
            }

            this.disposed = true;
        }
コード例 #6
0
 /// <summary>Disposes of the Enumerator object.</summary>
 public void Dispose()
 {
     ienum        = null;
     icurrentfile = null;
 }
コード例 #7
0
 internal Enumerator(IEnumBackgroundCopyFiles enumfiles)
 {
     ienum = enumfiles;
     ienum.Reset();
 }
コード例 #8
0
 internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList)
 {
     this.fileList = fileList;
     this.job      = job;
     this.Refresh();
 }