public static async Task <IEnumerable <TOut> > Process <TIn, TOut>( Func <IDistinctValuedDictionary <TIn, TIn>, Task <IDictionary <TIn, TOut> > > processor, IDistinctEnumerable <TIn> inputs) { var inputsByInput = inputs.ToDictionarySameKeyAndValue().AsDistinctValued(); var resultsByInput = await processor(inputsByInput); return(resultsByInput.Values); }
Task <IDictionary <string, bool> > IFileSystemOperator.ExistsFiles(IDistinctEnumerable <string> filePaths) { var output = new Dictionary <string, bool>(); foreach (var filePath in filePaths) { var fileExists = FileHelper.Exists(filePath); output.Add(filePath, fileExists); } return(Task.FromResult(output as IDictionary <string, bool>)); }
public static IDistinctEnumerable <string> GetFilePaths(this IStringlyTypedPathOperator stringlyTypedPathOperator, string directoryPath, IDistinctEnumerable <string> fileNames) { return(stringlyTypedPathOperator.GetFilePathsByFileName(directoryPath, fileNames) .Values .AsDistinct()); }
public static IDistinctValuedDictionary <string, string> GetFilePathsByFileName(this IStringlyTypedPathOperator stringlyTypedPathOperator, string directoryPath, IDistinctEnumerable <string> fileNames) { return(fileNames.ToDictionary( fileName => fileName, fileName => stringlyTypedPathOperator.GetFilePath(directoryPath, fileName)) .AsDistinctValued()); }
Task <IDictionary <string, IDistinctEnumerable <string> > > IFileSystemOperator.EnumerateFilePaths(IDistinctEnumerable <string> directoryPaths) { var output = new Dictionary <string, IDistinctEnumerable <string> >(); foreach (var directoryPath in directoryPaths) { var filePaths = DirectoryHelper.EnumerateFilePaths(directoryPath); output.Add(directoryPath, filePaths); } return(Task.FromResult(output as IDictionary <string, IDistinctEnumerable <string> >)); }
public static Task <IDictionary <string, string> > ReadContentsByFilePath(this IFileSystemOperator @operator, IDistinctEnumerable <string> filePaths) { var filePathsByFilePath = filePaths.ToDictionarySameKeyAndValue().AsDistinctValued(); var contentsByFilePath = @operator.ReadContentsByKey(filePathsByFilePath); return(contentsByFilePath); }