本文整理匯總了C#中BsonDocument.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonDocument.GetHashCode方法的具體用法?C# BsonDocument.GetHashCode怎麽用?C# BsonDocument.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.GetHashCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestBsonDocumentEquals
public void TestBsonDocumentEquals() {
BsonDocument lhs = new BsonDocument {
{ "Hello", "World" },
{ "Foo", "Bar" }
};
BsonDocument rhs = new BsonDocument(
new BsonElement("Hello", "World"),
new BsonElement("Foo", "Bar")
);
Assert.AreNotSame(lhs, rhs);
Assert.AreEqual(lhs, rhs);
Assert.AreEqual(lhs.GetHashCode(), rhs.GetHashCode());
}
示例2: TestGetHashcode
public void TestGetHashcode()
{
var bsonDocument = new BsonDocument { { "x", 1 }, { "y", 2 } };
var bson = bsonDocument.ToBson();
using (var rawBsonDocument = BsonSerializer.Deserialize<RawBsonDocument>(bson))
{
Assert.Equal(bsonDocument.GetHashCode(), rawBsonDocument.GetHashCode());
}
}
示例3: TestGetHashCode
public void TestGetHashCode()
{
var document = new BsonDocument("x", 1);
var hashCode = document.GetHashCode();
Assert.AreEqual(hashCode, document.GetHashCode()); // returns same value when called again
}
示例4: TryConvert_CastToBsonDocument
public void TryConvert_CastToBsonDocument()
{
// Dson holds a reference to Bson.
var bsonDoc = new BsonDocument("a", 1);
var dson = Dson.New(bsonDoc);
BsonDocument bsonDoc1 = dson;
var bsonDoc2 = dson.AsBsonDocument;
var bsonDoc3 = (BsonDocument)dson.AsBsonDocument;
Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc1.GetHashCode());
Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc2.GetHashCode());
Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc3.GetHashCode());
}