/// <summary>
        /// Serializes the checkpoint.
        /// </summary>
        /// <param name="info">Serialization info object.</param>
        /// <param name="context">Streaming context.</param>
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            List <SingleObjectTransfer> singleObjectTransfers = new List <SingleObjectTransfer>();
            List <DirectoryTransfer>    directoryTransfers    = new List <DirectoryTransfer>();

            foreach (var kv in this.transfers)
            {
                SingleObjectTransfer transfer = kv.Value as SingleObjectTransfer;
                if (transfer != null)
                {
                    singleObjectTransfers.Add(transfer);
                    continue;
                }

                DirectoryTransfer transfer2 = kv.Value as DirectoryTransfer;
                if (transfer2 != null)
                {
                    directoryTransfers.Add(transfer2);
                    continue;
                }
            }

            info.AddValue(SingleObjectTransfersName, singleObjectTransfers.Count);

            for (int i = 0; i < singleObjectTransfers.Count; ++i)
            {
                info.AddValue(string.Format(CultureInfo.InvariantCulture, "{0}{1}", SingleObjectTransfersName, i), singleObjectTransfers[i], typeof(SingleObjectTransfer));
            }

            info.AddValue(DirectoryTransfersName, directoryTransfers.Count);

            for (int i = 0; i < directoryTransfers.Count; ++i)
            {
                info.AddValue(string.Format(CultureInfo.InvariantCulture, "{0}{1}", DirectoryTransfersName, i), directoryTransfers[i], typeof(DirectoryTransfer));
            }
        }
        /// <summary>
        /// Gets a static snapshot of this transfer checkpoint
        /// </summary>
        /// <returns>A snapshot of current transfer checkpoint</returns>
        public TransferCollection Copy()
        {
            TransferCollection copyObj = new TransferCollection();

            foreach (var kv in this.transfers)
            {
                SingleObjectTransfer transfer = kv.Value as SingleObjectTransfer;
                if (transfer != null)
                {
                    copyObj.AddTransfer(transfer.Copy());
                    continue;
                }

                DirectoryTransfer transfer2 = kv.Value as DirectoryTransfer;
                if (transfer2 != null)
                {
                    copyObj.AddTransfer(transfer2.Copy());
                    continue;
                }
            }

            return(copyObj);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectoryTransfer"/> class.
 /// </summary>
 /// <param name="other">Another <see cref="DirectoryTransfer"/> object.</param>
 private DirectoryTransfer(DirectoryTransfer other)
     : base(other)
 {
     this.Initialize();
 }
Ejemplo n.º 4
0
 protected override void UpdateTransfer(Transfer transfer)
 {
     DirectoryTransfer.UpdateCredentials(this.Source, transfer.Source);
     DirectoryTransfer.UpdateCredentials(this.Destination, transfer.Destination);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectoryTransfer"/> class.
 /// </summary>
 /// <param name="other">Another <see cref="DirectoryTransfer"/> object.</param>
 private DirectoryTransfer(DirectoryTransfer other)
     : base(other)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectoryTransfer"/> class.
 /// </summary>
 /// <param name="other">Another <see cref="DirectoryTransfer"/> object.</param>
 private DirectoryTransfer(DirectoryTransfer other)
     : base(other)
 {
     this.Initialize();
 }
        private static DirectoryTransfer GetOrCreateDirectoryTransfer(TransferLocation sourceLocation, TransferLocation destLocation, TransferMethod transferMethod, TransferContext transferContext)
        {
            DirectoryTransfer directoryTransfer = null;
            Transfer transfer = GetTransfer(sourceLocation, destLocation, transferMethod, transferContext);
            if (transfer == null)
            {
                directoryTransfer = new DirectoryTransfer(sourceLocation, destLocation, transferMethod);

                if (transferContext != null)
                {
                    transferContext.Checkpoint.AddTransfer(directoryTransfer);
                }
            }
            else
            {
                directoryTransfer = transfer as DirectoryTransfer;
                Debug.Assert(directoryTransfer != null, "directoryTransfer");
            }

            directoryTransfer.MaxTransferConcurrency = configurations.ParallelOperations * Constants.ListSegmentLengthMultiplier;
            return directoryTransfer;
        }