示例#1
0
 public static BsonDocument GetFlatDocument(BsonDocument document, EnumerateElementsOptions options = EnumerateElementsOptions.None)
 {
     //return new BsonDocument(new EnumerateElements { Options = options }.GetElements(document));
     //BsonDocument flatDocument = new BsonDocument();
     //flatDocument.AllowDuplicateNames = true;
     //flatDocument.AddRange(new EnumerateElements { Options = options }.GetElements(document));
     //foreach (BsonElement element in new EnumerateElements { Options = options }.GetElements(document))
     //{
     //    if (!flatDocument.Contains(element.Name))
     //        flatDocument.Add(element);
     //    else
     //        Trace.WriteLine("warning duplicate \"{0}\" : value1 {1} value2 {2}", element.Name, flatDocument[element.Name], element.Value);
     //}
     //return flatDocument;
     return(new EnumerateElements {
         Options = options
     }.GetFlatDocument(document));
 }
 public static IEnumerable<BsonElement> GetFlatElements(BsonDocument document, EnumerateElementsOptions options = EnumerateElementsOptions.None)
 {
     return new EnumerateElements { Options = options }.GetElements(document);
 }
 public static BsonDocument GetFlatDocument(BsonDocument document, EnumerateElementsOptions options = EnumerateElementsOptions.None)
 {
     //return new BsonDocument(new EnumerateElements { Options = options }.GetElements(document));
     //BsonDocument flatDocument = new BsonDocument();
     //flatDocument.AllowDuplicateNames = true;
     //flatDocument.AddRange(new EnumerateElements { Options = options }.GetElements(document));
     //foreach (BsonElement element in new EnumerateElements { Options = options }.GetElements(document))
     //{
     //    if (!flatDocument.Contains(element.Name))
     //        flatDocument.Add(element);
     //    else
     //        Trace.WriteLine("warning duplicate \"{0}\" : value1 {1} value2 {2}", element.Name, flatDocument[element.Name], element.Value);
     //}
     //return flatDocument;
     return new EnumerateElements { Options = options }.GetFlatDocument(document);
 }
示例#4
0
 public static CompareBsonDocumentsResult CompareBsonDocuments(BsonDocument document1, BsonDocument document2,
     BsonDocumentComparatorOptions comparatorOptions = BsonDocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
     IEnumerable<string> elementsToCompare = null)
 {
     BsonDocumentComparator comparator = new BsonDocumentComparator();
     comparator.SetComparatorOptions(comparatorOptions);
     comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
     comparator.SetElementsToCompare(elementsToCompare);
     return comparator.CompareBsonDocuments(new TwoBsonDocuments { Document1 = document1, Document2 = document2 });
 }
示例#5
0
        public static IEnumerable<CompareBsonDocumentsResult> CompareBsonDocumentFiles(string file1, string file2,
            BsonDocumentComparatorOptions comparatorOptions = BsonDocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
            IEnumerable<string> elementsToCompare = null, IEnumerable<string> documentReference = null)
        {
            var query = EnumarateTwoBsonDocumentsList(zmongo.BsonRead<BsonDocument>(file1), zmongo.BsonRead<BsonDocument>(file2));

            BsonDocumentComparator comparator = new BsonDocumentComparator();
            comparator.SetComparatorOptions(comparatorOptions);
            comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
            comparator.SetElementsToCompare(elementsToCompare);
            comparator.SetDocumentReference(documentReference);
            return comparator.Compare(query);
        }
示例#6
0
        public static IEnumerable<CompareBsonDocumentsResult> CompareBsonDocumentFilesWithKey(string file1, string file2, string key1, string key2, JoinType joinType = JoinType.InnerJoin,
            BsonDocumentComparatorOptions comparatorOptions = BsonDocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
            IEnumerable<string> elementsToCompare = null)
        {
            IEnumerable<TwoBsonDocuments> query =
                zmongo.BsonRead<BsonDocument>(file1).zJoin(
                    zmongo.BsonRead<BsonDocument>(file2),
                    document1 => document1[key1],
                    document2 => document2[key2],
                    (document1, document2) => new TwoBsonDocuments { Key = document1 != null ? document1.zGet(key1) : document2.zGet(key2), Document1 = document1, Document2 = document2 },
                    joinType);

            BsonDocumentComparator comparator = new BsonDocumentComparator();
            comparator.SetComparatorOptions(comparatorOptions);
            comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
            comparator.SetElementsToCompare(elementsToCompare);
            return comparator.Compare(query);
        }
示例#7
0
 public void SetEnumerateElementsOptions(EnumerateElementsOptions enumerateElementsOptions)
 {
     _enumerateElementsOptions = enumerateElementsOptions;
 }
示例#8
0
 public static IEnumerable <BsonElement> GetFlatElements(BsonDocument document, EnumerateElementsOptions options = EnumerateElementsOptions.None)
 {
     return(new EnumerateElements {
         Options = options
     }.GetElements(document));
 }
示例#9
0
        public static CompareDocumentResult CompareBsonDocuments(BsonDocument document1, BsonDocument document2,
                                                                 DocumentComparatorOptions comparatorOptions = DocumentComparatorOptions.ReturnNotEqualDocuments, EnumerateElementsOptions enumerateElementsOptions = EnumerateElementsOptions.None,
                                                                 IEnumerable <string> elementsToCompare      = null)
        {
            DocumentComparator comparator = new DocumentComparator();

            comparator.SetComparatorOptions(comparatorOptions);
            comparator.SetEnumerateElementsOptions(enumerateElementsOptions);
            comparator.SetElementsToCompare(elementsToCompare);
            return(comparator.CompareBsonDocuments(new TwoDocuments {
                Document1 = document1, Document2 = document2
            }));
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
0
 public void SetEnumerateElementsOptions(EnumerateElementsOptions enumerateElementsOptions)
 {
     _enumerateElementsOptions = enumerateElementsOptions;
 }