private FileSorting CreateSorting(FileSortingRule ruleToCreate, FileSortingConfiguration configuration) { var finder = LoadHandler(ruleToCreate.FinderNames, configuration.Finder); var filter = LoadHandler(ruleToCreate.FilterNames, configuration.Filter); var informationExtractor = LoadHandler(ruleToCreate.InformationExtractorNames, configuration.InformationExtractor); var informationMapper = LoadHandler(ruleToCreate.InformationMapperNames, configuration.InformationMapper); var fileInformationFilter = LoadHandler(ruleToCreate.InformationFilterNames, configuration.InformationFilter); var pathCreator = LoadHandler(ruleToCreate.PathCreatorName, configuration.Creator); FilePathCreator backupPathCreator = null; if (!string.IsNullOrEmpty(ruleToCreate.BackupPathCreatorName)) { backupPathCreator = LoadHandler(ruleToCreate.BackupPathCreatorName, configuration.Creator); } var mover = LoadHandler(ruleToCreate.MoverName, configuration.Mover); var changer = LoadHandler(ruleToCreate.FileContentChanger, configuration.ContentChanger); var indexer = LoadHandler(ruleToCreate.Indexer, configuration.Indexer); return(new FileSorting(ruleToCreate.Priority, finder.ToArray(), filter.ToArray(), informationExtractor.ToArray(), informationMapper.ToArray(), fileInformationFilter.ToArray(), pathCreator, backupPathCreator, mover, changer.ToArray(), indexer.ToArray())); }
public FileSorting(int priority, FileFinder[] fileFinder, FileFilter[] fileFilter, FileInformationExtractor[] fileInformationExtractor, FileInformationMapper[] fileInformationMapper, FileInformationFilter[] fileInformationFilter, FilePathCreator filePathCreator, FilePathCreator backupFilePathCreator, FileMover fileMover, FileContentChanger[] fileContentChanger, FileIndexer[] fileIndexer) { Priority = priority; FileFinder = fileFinder ?? throw new ArgumentNullException("fileFinder"); FileFilter = fileFilter ?? throw new ArgumentNullException("fileFilter"); FileInformationExtractor = fileInformationExtractor ?? throw new ArgumentNullException("fileInformationExtractor"); FileInformationMapper = fileInformationMapper ?? throw new ArgumentNullException(nameof(fileInformationMapper)); FileInformationFilter = fileInformationFilter ?? throw new ArgumentNullException("fileInformationFilter"); FilePathCreator = filePathCreator ?? throw new ArgumentNullException("filePathCreator"); BackupFilePathCreator = backupFilePathCreator; FileMover = fileMover ?? throw new ArgumentNullException("fileMover"); FileContentChanger = fileContentChanger ?? throw new ArgumentNullException("fileConentChanger"); FileIndexer = fileIndexer ?? throw new ArgumentNullException("indexer"); if (fileFinder.Length == 0) { throw new ArgumentException("Minimal one fileFinder must be availible"); } if (fileInformationExtractor.Length == 0) { throw new ArgumentException("Minimal one FileInformationExtractor must be availible"); } }