/// <summary>
 /// Parameterless constructor.
 /// </summary>
 public PersistedDownloadTransfer()
     : base()
 {
     _Method = "GET";
     //_Headers = new KeyValuePair<string, string>();
     _TransferStatus = ExtendedTransferStatus.None;
     _FailedTransferAttempts = 0;
     _IsIndeterminateTransfer = false;
     _TotalBytesToReceive = -1;
     _BytesReceived = 0;
     _RequestId = string.Empty;
 }
        /// <summary>
        /// Handler for the OnStatusChange event of a ITransferable object associated with a Page.
        /// </summary>
        /// <param name="Previous">The transfer status that the ITransferable object had before changing.</param>
        /// <param name="Current">The transfer status that the ITransferable object currently has.</param>
        public void StatusChangeHandler(ExtendedTransferStatus Previous, ExtendedTransferStatus Current, ITransferable Item)
        {
            Library.Page Page = FindByUID(Item.ExternalReference);

            if (Page != null)
            {
                // Then add the item to the related collection based on its current status
                switch (Current)
                {
                    case ExtendedTransferStatus.Queued:
                    case ExtendedTransferStatus.Transferring:
                    case ExtendedTransferStatus.Waiting:
                    case ExtendedTransferStatus.WaitingForRetry:
                    case ExtendedTransferStatus.WaitingForWiFi:
                    case ExtendedTransferStatus.WaitingForExternalPower:
                    case ExtendedTransferStatus.WaitingForExternalPowerDueToBatterySaverMode:
                    case ExtendedTransferStatus.WaitingForNonVoiceBlockingNetwork:
                    case ExtendedTransferStatus.Paused:
                    case ExtendedTransferStatus.Canceled:
                        if (Previous == ExtendedTransferStatus.Completed)
                        {
                            _DownloadedPages.Remove(Page);
                            _PendingPages.Add(Page);
                        }
                        else if (Previous == ExtendedTransferStatus.Failed || Previous == ExtendedTransferStatus.FailedServer)
                        {
                            _FailedPages.Remove(Page);
                            _PendingPages.Add(Page);
                        }
                        break;
                    case ExtendedTransferStatus.Completed:
                        if (Previous == ExtendedTransferStatus.Failed || Previous == ExtendedTransferStatus.FailedServer)
                        {
                            _FailedPages.Remove(Page);
                            _DownloadedPages.Add(Page);
                        }
                        else if (Previous != ExtendedTransferStatus.Completed)
                        {
                            _PendingPages.Remove(Page);
                            _DownloadedPages.Add(Page);
                        }

                        break;
                    case ExtendedTransferStatus.Failed:
                    case ExtendedTransferStatus.FailedServer:
                        if (Previous == ExtendedTransferStatus.Completed)
                        {
                            _DownloadedPages.Remove(Page);
                            _FailedPages.Add(Page);
                        }
                        else if (Previous != ExtendedTransferStatus.Failed && Previous != ExtendedTransferStatus.FailedServer)
                        {
                            _PendingPages.Remove(Page);
                            _FailedPages.Add(Page);
                        }
                        break;
                }
            }
        }