本文整理汇总了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());
}