示例#1
0
        public static void Test_BsonDocument_CompareTo_01()
        {
            BsonDocument document1 = new BsonDocument {
                { "id1", "toto" }
            };
            BsonDocument document2 = new BsonDocument {
                { "id1", "toto" }
            };
            BsonDocument document3 = new BsonDocument {
                { "id1", "toto2" }
            };

            if (document1.CompareTo(document2) == 0)
            {
                Trace.WriteLine("document1 and document2 are identical");
            }
            else
            {
                Trace.WriteLine("document1 and document2 are different");
            }
            if (document1.CompareTo(document3) == 0)
            {
                Trace.WriteLine("document1 and document3 are identical");
            }
            else
            {
                Trace.WriteLine("document1 and document3 are different");
            }
        }
示例#2
0
        /// <summary>
        /// Compares this BsonJavaScriptWithScope to another BsonJavaScriptWithScope.
        /// </summary>
        /// <param name="other">The other BsonJavaScriptWithScope.</param>
        /// <returns>A 32-bit signed integer that indicates whether this BsonJavaScriptWithScope is less than, equal to, or greather than the other.</returns>
        public int CompareTo(BsonJavaScriptWithScope other)
        {
            if (other == null)
            {
                return(1);
            }
            int r = Code.CompareTo(other.Code);

            if (r != 0)
            {
                return(r);
            }
            return(_scope.CompareTo(other._scope));
        }
 private static void AssertEquals(BsonDocument doc1, BsonDocument doc2)
 {
     if (doc1.CompareTo(doc2) != 0)
     {
         Assert.AreEqual(doc1.ToJson(), doc2.ToJson());
     }
 }