本文整理汇总了C#中BsonClassMap.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# BsonClassMap.Freeze方法的具体用法?C# BsonClassMap.Freeze怎么用?C# BsonClassMap.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonClassMap
的用法示例。
在下文中一共展示了BsonClassMap.Freeze方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestUnmap
public void TestUnmap()
{
var classMap = new BsonClassMap<C>(cm =>
{
cm.AutoMap();
cm.SetIdMember(cm.GetMemberMap("Id"));
cm.UnmapField("Id");
cm.UnmapField("FieldUnmappedByName");
cm.UnmapField(c => c.FieldUnmappedByLambda);
cm.UnmapProperty("PropertyUnmappedByName");
cm.UnmapProperty(c => c.PropertyUnmappedByLambda);
});
classMap.Freeze();
Assert.IsNull(classMap.IdMemberMap);
Assert.AreEqual(1, classMap.AllMemberMaps.Count());
var memberMap = classMap.AllMemberMaps.Single();
Assert.AreEqual("X", memberMap.MemberName);
}
示例2: TestSetCreator
public void TestSetCreator()
{
var classMap = new BsonClassMap<B>(cm =>
{
cm.AutoMap();
cm.SetCreator(() => new B(10));
});
classMap.Freeze();
var instance = (B)classMap.CreateInstance();
Assert.AreEqual(10, instance.A);
}
示例3: TestAllValuesGoBackToTheirDefaults
public void TestAllValuesGoBackToTheirDefaults()
{
var classMap = new BsonClassMap<TestClass>(cm =>
{
cm.SetCreator(() => { throw new Exception("will get reset."); });
cm.MapMember(x => x.String);
cm.SetDiscriminator("blah");
cm.SetDiscriminatorIsRequired(true);
cm.MapExtraElementsMember(x => x.ExtraElements);
cm.MapIdMember(x => x.OId);
cm.SetIgnoreExtraElements(false);
cm.SetIgnoreExtraElementsIsInherited(true);
cm.SetIsRootClass(true);
cm.AddKnownType(typeof(InheritedTestClass));
});
classMap.Reset();
classMap.Freeze();
Assert.DoesNotThrow(() => classMap.CreateInstance());
Assert.AreEqual(0, classMap.DeclaredMemberMaps.Count());
Assert.AreEqual("TestClass", classMap.Discriminator);
Assert.IsFalse(classMap.DiscriminatorIsRequired);
Assert.IsNull(classMap.ExtraElementsMemberMap);
Assert.IsNull(classMap.IdMemberMap);
Assert.IsTrue(classMap.IgnoreExtraElements);
Assert.IsFalse(classMap.IgnoreExtraElementsIsInherited);
Assert.IsFalse(classMap.IsRootClass);
Assert.AreEqual(0, classMap.KnownTypes.Count());
}