本文整理汇总了C#中BsonClassMap.MapExtraElementsMember方法的典型用法代码示例。如果您正苦于以下问题:C# BsonClassMap.MapExtraElementsMember方法的具体用法?C# BsonClassMap.MapExtraElementsMember怎么用?C# BsonClassMap.MapExtraElementsMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonClassMap
的用法示例。
在下文中一共展示了BsonClassMap.MapExtraElementsMember方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostProcess
public void PostProcess(BsonClassMap classMap)
{
var memberName = _convention.FindExtraElementsMember(classMap.ClassType);
if (string.IsNullOrEmpty(memberName))
{
return;
}
var memberInfo = classMap.ClassType.GetMember(memberName, MemberTypes.Field | MemberTypes.Property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).SingleOrDefault();
if (memberInfo == null)
{
return;
}
classMap.MapExtraElementsMember(memberInfo);
}
示例2: Apply
// public methods
/// <summary>
/// Applies a modification to the class map.
/// </summary>
/// <param name="classMap">The class map.</param>
public void Apply(BsonClassMap classMap)
{
foreach (var name in _names)
{
var member = classMap.ClassType.GetMember(name, _memberTypes, _bindingFlags).SingleOrDefault();
if (member != null)
{
Type memberType = null;
var fieldInfo = member as FieldInfo;
if (fieldInfo != null)
{
memberType = fieldInfo.FieldType;
}
else
{
var propertyInfo = member as PropertyInfo;
if (propertyInfo != null)
{
memberType = propertyInfo.PropertyType;
}
}
if (memberType != null && (memberType == typeof(BsonDocument) || typeof(IDictionary<string, object>).IsAssignableFrom(memberType)))
{
classMap.MapExtraElementsMember(member);
return;
}
}
}
}