예제 #1
0
 public DownloadDirectoriesCreator(
     IncompleteDownloadsDirectory incompleteDownloadsDirectory,
     CompletedDownloadsDirectory completedDownloadsDirectory,
     IFileSystem fileSystem,
     ILogger <DownloadDirectoriesCreator> logger)
 {
     _incompleteDownloadsDirectory = incompleteDownloadsDirectory;
     _completedDownloadsDirectory  = completedDownloadsDirectory;
     _fileSystem = fileSystem;
     _logger     = logger;
 }
예제 #2
0
 public DownloadController(
     DownloadManager downloadManager,
     NotificationsManager notificationsManager,
     DownloadStarter downloadStarter,
     CompletedDownloadsDirectory completedDownloadsDirectory,
     DownloadJobsDictionary jobs)
 {
     _downloadManager             = downloadManager;
     _notificationsManager        = notificationsManager;
     _downloadStarter             = downloadStarter;
     _completedDownloadsDirectory = completedDownloadsDirectory;
     _jobs = jobs;
 }
예제 #3
0
 public static Result <SaveAsFile> Create(
     Link link,
     CompletedDownloadsDirectory downloadDirectoryPath,
     string fileName = "")
 {
     fileName = string.IsNullOrWhiteSpace(fileName) ? link.FileName : fileName;
     try
     {
         return(new SaveAsFile(downloadDirectoryPath, fileName));
     }
     catch (ArgumentException e)
     {
         return(Result.Failure <SaveAsFile>(e.Message));
     }
 }
예제 #4
0
        private SaveAsFile(
            CompletedDownloadsDirectory downloadsDirectory,
            string fileName,
            int seq = 0)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(fileName));
            }

            _downloadsDirectory = downloadsDirectory;

            (_nameWithoutExtension, _extension) = SplitNameAndExtension(fileName);
            _seq = seq >= 0 ? seq : throw new ArgumentOutOfRangeException(nameof(seq), seq, "must not be negative");

            Name = _seq > 0
                ? $"{_nameWithoutExtension}({_seq}){_extension}"
                : $"{_nameWithoutExtension}{_extension}";
            FullName = $"{_downloadsDirectory}{Name}";
        }