本文整理汇总了C#中System.Reflection.MemberInfo.GetActualType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetActualType方法的具体用法?C# MemberInfo.GetActualType怎么用?C# MemberInfo.GetActualType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.GetActualType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMapping
static void AddMapping(LightDBDefinitionSet defs, TableDefinition[] defaultTables, SimpleFlatFieldDefinition fieldDef,
Dictionary<string, List<SimpleDataColumn>> mappedFields, IFlatDataFieldAccessor accessor, MemberInfo member)
{
var column = fieldDef.Column;
var tables = defs.EnsureTables(fieldDef.Table, defaultTables);
object defaultValue;
if (!String.IsNullOrEmpty(fieldDef.DefaultStringValue))
{
defaultValue = StringParser.Parse(fieldDef.DefaultStringValue, member.GetVariableType());
}
else
{
if (String.IsNullOrEmpty(column))
{
return;
}
defaultValue = null;
}
foreach (var table in tables)
{
var dataHolders = defs.m_tableDataHolderMap.GetOrCreate(table);
if (!dataHolders.Contains(accessor.DataHolderDefinition))
{
dataHolders.Add(accessor.DataHolderDefinition);
}
var mappedFieldMap = mappedFields.GetOrCreate(table.Name);
SimpleDataColumn dataColumn;
var dbAttrs = member.GetCustomAttributes<DBAttribute>();
var attr = dbAttrs.Where(attribute => attribute is PersistentAttribute).FirstOrDefault() as PersistentAttribute;
if (String.IsNullOrEmpty(column))
{
// use default value
mappedFieldMap.Add(dataColumn = new SimpleDataColumn(fieldDef.Name, defaultValue));
}
else
{
dataColumn = mappedFieldMap.Find((cmpField) => cmpField.ColumnName == column);
if (dataColumn == null)
{
var type = member.GetActualType();
if (attr != null)
type = attr.ReadType ?? type;
var reader = Converters.GetReader(type);
mappedFieldMap.Add(dataColumn = new SimpleDataColumn(column, reader));
}
}
dataColumn.FieldList.Add(accessor);
}
}
示例2: AddMapping
static void AddMapping(LightDBDefinitionSet defs, TableDefinition[] defaultTables, SimpleFlatFieldDefinition fieldDef,
Dictionary<string, List<SimpleDataColumn>> mappedFields, IFlatDataFieldAccessor accessor, MemberInfo member)
{
var column = fieldDef.Column;
var tables = defs.EnsureTables(fieldDef.Table, defaultTables);
object defaultValue;
if (!String.IsNullOrEmpty(fieldDef.DefaultStringValue))
{
defaultValue = Utility.Parse(fieldDef.DefaultStringValue, member.GetVariableType());
}
else
{
if (String.IsNullOrEmpty(column))
{
return;
}
defaultValue = null;
}
if (accessor.DataHolderDefinition.Type.Name.EndsWith("TrainerEntry"))
{
defs.ToString();
}
foreach (var table in tables)
{
var dataHolders = defs.m_tableDataHolderMap.GetOrCreate(table);
if (!dataHolders.Contains(accessor.DataHolderDefinition))
{
dataHolders.Add(accessor.DataHolderDefinition);
}
var mappedFieldMap = mappedFields.GetOrCreate(table.Name);
SimpleDataColumn dataColumn;
if (String.IsNullOrEmpty(column))
{
// use default value
mappedFieldMap.Add(dataColumn = new SimpleDataColumn(fieldDef.Name, defaultValue));
}
else
{
dataColumn = mappedFieldMap.Find((cmpField) => cmpField.ColumnName == column);
if (dataColumn == null)
{
mappedFieldMap.Add(dataColumn = new SimpleDataColumn(column, Converters.GetReader(member.GetActualType())));
}
}
dataColumn.FieldList.Add(accessor);
}
}