private List <MatchResult> GetFileDuplicates(IComparableFile fileToFind, IEnumerable <IComparableFile> fileGroup, SearchContext context, CancellationToken cancellationToken) { var duplicates = new List <MatchResult>(); var matchThreshold = context.ComparerConfig.MatchThreshold.Value; var completeMatch = context.ComparerConfig.CompleteMatch.Value; var completeMismatch = context.ComparerConfig.CompleteMismatch.Value; foreach (var fileFromGroup in fileGroup) { if (ReferenceEquals(fileFromGroup, fileToFind)) { continue; //Skip self } int matchValue; try { if ((matchValue = fileToFind.CompareTo(fileFromGroup, cancellationToken)) < matchThreshold) { continue; } } catch (OperationCanceledException) { throw; } catch (FileSystemException ex) { OnFileSystemError(ex.FileFullName, ex.Message, ex); continue; } catch (Exception ex) { OnFileSystemError(fileFromGroup.FileData.FullName, ex.Message, ex); continue; } if (duplicates.Count == 0) { duplicates.Add(new MatchResult { ComparableFile = fileToFind, MatchValue = completeMatch, CompleteMatch = completeMatch, CompleteMismatch = completeMismatch }); } duplicates.Add(new MatchResult { ComparableFile = fileFromGroup, MatchValue = matchValue, CompleteMatch = completeMatch, CompleteMismatch = completeMismatch }); } return(duplicates); }