コード例 #1
0
        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);
        }
コード例 #2
0
        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>));
        }
コード例 #3
0
 public static IDistinctEnumerable <string> GetFilePaths(this IStringlyTypedPathOperator stringlyTypedPathOperator, string directoryPath, IDistinctEnumerable <string> fileNames)
 {
     return(stringlyTypedPathOperator.GetFilePathsByFileName(directoryPath, fileNames)
            .Values
            .AsDistinct());
 }
コード例 #4
0
 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());
 }
コード例 #5
0
        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> >));
        }
コード例 #6
0
        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);
        }