コード例 #1
0
        private async Task <IReadOnlyList <TargetDirectory> > ProcessFilesAsync(IReadOnlyList <FileRecord> records,
                                                                                CancellationToken cancellationToken)
        {
            var outputs = new Dictionary <string, TargetDirectory>();

            foreach (var record in records)
            {
                var key = record.GetTargetKey();

                if (!outputs.TryGetValue(key, out var targetDirectory))
                {
                    targetDirectory = await TargetDirectory.FromRecordAsync(_directories, record);

                    outputs[key] = targetDirectory;
                }
                else
                {
                    targetDirectory.SourceRecords.Add(record);
                }
            }

            return(outputs.Values.ToArray());
        }