/// <summary> Copies the elements of the <see cref="ICollection{T}" /> to an <see cref="Array" />, starting at a particular <see cref="Array" /> index.
        /// </summary> <param name="array">The one-dimensional <see cref="Array" /> that is the destination of the elements copied from <see
        /// cref="ICollection{T}" />. The <see cref="Array" /> must have zero-based indexing.</param> <param name="arrayIndex">The zero-based index in <paramref
        /// name="array" /> at which copying begins.</param> <exception cref="NotImplementedException"></exception>
        void ICollection <BackgroundCopyJob> .CopyTo(BackgroundCopyJob[] array, int arrayIndex)
        {
            var ijobs = BackgroundCopyManager.EnumJobs((BG_JOB_ENUM)JobListRights);
            var cnt   = ijobs.GetCount();

            Array.Copy(Array.ConvertAll(ijobs.Next(cnt), i => new BackgroundCopyJob(i)), 0, array, arrayIndex, cnt);
        }
 /// <summary>Gets the <see cref="BackgroundCopyJob"/> object with the specified job identifier.</summary>
 /// <param name="jobId">Unique identifier of the job.</param>
 /// <returns>The referenced <see cref="BackgroundCopyJob"/> object if found, null if not.</returns>
 public BackgroundCopyJob this[Guid jobId]
 {
     get
     {
         var job = BackgroundCopyManager.GetJob(jobId);
         return(job != null ? new BackgroundCopyJob(job) : throw new KeyNotFoundException());
     }
 }
예제 #3
0
 internal BackgroundCopyException(COMException cex)
 {
     code    = cex.ErrorCode;
     errDesc = BackgroundCopyManager.GetErrorMessage(code);
     if (errDesc == null)
     {
         code.ThrowIfFailed();
     }
 }
 /// <summary>Determines whether the <see cref="ICollection{T}"/> contains a specific value.</summary>
 /// <param name="jobId">The object to locate in the <see cref="ICollection{T}"/>.</param>
 /// <returns>true if <paramref name="jobId"/> is found in the <see cref="ICollection{T}"/>; otherwise, false.</returns>
 public bool Contains(Guid jobId)
 {
     try
     {
         var ijob = BackgroundCopyManager.GetJob(jobId);
         return(ijob != null);
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>Creates a new upload or download transfer job.</summary>
 /// <param name="displayName">Name of the job.</param>
 /// <param name="description">Description of the job.</param>
 /// <param name="jobType">Type (upload or download) of the job.</param>
 /// <returns>The new <see cref="BackgroundCopyJob"/>.</returns>
 public BackgroundCopyJob Add(string displayName, string description = "", BackgroundCopyJobType jobType = BackgroundCopyJobType.Download)
 {
     try
     {
         var job = new BackgroundCopyJob(BackgroundCopyManager.CreateJob(displayName, (BG_JOB_TYPE)jobType));
         if (!string.IsNullOrEmpty(description))
         {
             job.Description = description;
         }
         return(job);
     }
     catch (COMException cex)
     {
         BackgroundCopyManager.HandleCOMException(cex);
     }
     return(null);
 }
        /// <summary>Returns an enumerator that iterates through the collection.</summary>
        /// <returns>A <see cref="IEnumerator{T}"/> that can be used to iterate through the collection.</returns>
        public IEnumerator <BackgroundCopyJob> GetEnumerator()
        {
            var ienum = BackgroundCopyManager.EnumJobs((BG_JOB_ENUM)JobListRights);

            return(new Enumerator(ienum));
        }