本文整理汇总了C#中BsonClassMap.SetDiscriminator方法的典型用法代码示例。如果您正苦于以下问题:C# BsonClassMap.SetDiscriminator方法的具体用法?C# BsonClassMap.SetDiscriminator怎么用?C# BsonClassMap.SetDiscriminator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonClassMap
的用法示例。
在下文中一共展示了BsonClassMap.SetDiscriminator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
// public methods
/// <summary>
/// Applies a modification to the class map.
/// </summary>
/// <param name="classMap">The class map.</param>
public void Apply(BsonClassMap classMap)
{
if (_discriminator != null)
{
classMap.SetDiscriminator(_discriminator);
}
classMap.SetDiscriminatorIsRequired(_required);
classMap.SetIsRootClass(_rootClass);
}
示例2: RegisterClassWithDiscriminator
public void RegisterClassWithDiscriminator(Type type)
{
string name = _mapper.GetFieldName(type);
BsonClassMap cm = new BsonClassMap(type);
cm.AutoMap();
cm.SetDiscriminator(name);
ExtraRegistrationSteps(type, cm); // Derived classes can implement this if they need to.
BsonClassMap.RegisterClassMap(cm);
// Don't need to RegisterDiscriminatorConvention for each subclass, only for the base class.
//BsonSerializer.RegisterDiscriminatorConvention(type, new ScalarDiscriminatorConvention("type"));
}