示例#1
0
        protected override DownloadSlot InitDownloadSlot()
        {
            DownloadSlot downloadSlot = new DownloadSlot();

            downloadSlot.State = DownloadState.Downloading;
            return(downloadSlot);
        }
示例#2
0
        public DownloadSlotViewModel(DownloadSlot downloadSlot, INetworkClient downloadingClient,
                                     IFileStreamClient fileStreamClient)
        {
            if (downloadSlot == null)
            {
                throw new ArgumentNullException("downloadSlot");
            }
            if (downloadingClient == null)
            {
                throw new ArgumentNullException("downloadingClient");
            }
            if (fileStreamClient == null)
            {
                throw new ArgumentNullException("fileStreamClient");
            }

            this.downloadSlot      = downloadSlot;
            this.downloadingClient = downloadingClient;
            this.fileStreamClient  = fileStreamClient;

            this.downloadingClient.OnBlockDownloaded += downloadingClientOnBlockDownloaded;
            this.downloadingClient.OnError           += downloadingClientOnError;
            this.downloadingClient.OnRestore         += downloadingClientOnRestore;
            this.downloadingClient.OnComplete        += downloadingClientOnComplete;
        }
示例#3
0
        private DownloadSlot createDownloadSlot()
        {
            DownloadSlot downloadSlot = new DownloadSlot();

            this.downloadSlotsModel.DownloadSlots.Add(downloadSlot);
            return(downloadSlot);
        }
示例#4
0
 protected override void Establish_context()
 {
     base.Establish_context();
     DownloadSlot          = InitDownloadSlot();
     NetworkClient         = new Mock <INetworkClient>();
     FileStreamClient      = new Mock <IFileStreamClient>();
     DownloadSlotViewModel = new DownloadSlotViewModel(DownloadSlot, NetworkClient.Object, FileStreamClient.Object);
 }
示例#5
0
        protected override DownloadSlot InitDownloadSlot()
        {
            DownloadSlot downloadSlot = new DownloadSlot();

            downloadSlot.StartPosition   = startPosition;
            downloadSlot.CurrentPosition = currentPosition;
            downloadSlot.FinishPosition  = finishPosition;
            downloadSlot.State           = DownloadState.Initializing;
            return(downloadSlot);
        }
示例#6
0
        private DownloadSlotViewModel createDownloadSlotViewModel(DownloadSlot downloadSlot)
        {
            DownloadSlotViewModel downloadSlotViewModel =
                new DownloadSlotViewModel(downloadSlot,
                                          downloadingClientFactory.CreateClient(downloadSlotsModel),
                                          fileStreamClientFactory.CreateFileStreamClient(downloadSlotsModel));

            this.items.Add(downloadSlotViewModel);
            return(downloadSlotViewModel);
        }
示例#7
0
        private void addDownloadSlot(DownloadSlot downloadSlot)
        {
            DownloadSlotViewModel downloadSlotViewModel = this.createDownloadSlotViewModel(downloadSlot);

            downloadSlotViewModel.OnRemove += () =>
            {
                this.removeFromDownloadSlotModels(downloadSlot);
                this.removeFromDownloadSlotViewModels(downloadSlotViewModel);
            };
            downloadSlotViewModel.OnDownloaded += downloadSlotViewModelOnDownloaded;
            downloadSlotViewModel.OnComplete   += downloadSlotViewModelOnComplete;
            downloadSlotViewModel.OnError      += downloadSlotViewModelOnError;
            downloadSlotViewModel.OnRestore    += downloadSlotViewModelOnRestore;
        }
示例#8
0
 private void removeFromDownloadSlotModels(DownloadSlot downloadSlot)
 {
     this.downloadSlotsModel.DownloadSlots.Remove(downloadSlot);
 }