示例#1
0
        // IEnumerable<CompareDocumentResult>
        public static CompareDocumentsResult CompareBsonDocumentFilesWithKey(string file1, string file2, string key1, string key2, JoinType joinType = JoinType.InnerJoin,
                                                                             DocumentComparatorOptions comparatorOptions = DocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
                                                                             IEnumerable <string> elementsToCompare      = null)
        {
            IEnumerable <TwoDocuments> query =
                zMongo.BsonRead <BsonDocument>(file1).zJoin(
                    zMongo.BsonRead <BsonDocument>(file2),
                    document1 => document1[key1],
                    document2 => document2[key2],
                    (document1, document2) => new TwoDocuments {
                Key = document1 != null ? document1.zGet(key1) : document2.zGet(key2), Document1 = document1, Document2 = document2
            },
                    joinType);

            DocumentComparator comparator = new DocumentComparator();

            comparator.SetComparatorOptions(comparatorOptions);
            comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
            comparator.SetElementsToCompare(elementsToCompare);
            CompareDocumentsResult result = comparator.Compare(query);

            result.Source1 = file1;
            result.Source2 = file2;
            return(result);
        }
示例#2
0
        public CompareDocumentsResult Compare(IEnumerable <TwoDocuments> twoBsonDocumentsList)
        {
            CompareDocumentsResult resultAggregate = new CompareDocumentsResult();

            foreach (CompareDocumentResult result in _Compare(twoBsonDocumentsList))
            {
                bool equal = result.Equal;
                resultAggregate.AddResult(result, (!equal && _returnNotEqualDocuments) || (equal && _returnEqualDocuments));
            }
            return(resultAggregate);
        }
示例#3
0
        // IEnumerable<CompareDocumentResult>
        public static CompareDocumentsResult CompareBsonDocumentFiles(string file1, string file2,
                                                                      DocumentComparatorOptions comparatorOptions = DocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
                                                                      IEnumerable <string> elementsToCompare      = null, IEnumerable <string> documentReference = null)
        {
            var query = EnumarateTwoBsonDocumentsList(zMongo.BsonRead <BsonDocument>(file1), zMongo.BsonRead <BsonDocument>(file2));

            DocumentComparator comparator = new DocumentComparator();

            comparator.SetComparatorOptions(comparatorOptions);
            comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
            comparator.SetElementsToCompare(elementsToCompare);
            comparator.SetDocumentReference(documentReference);
            CompareDocumentsResult result = comparator.Compare(query);

            result.Source1 = file1;
            result.Source2 = file2;
            return(result);
        }