本文整理汇总了C#中System.Reflection.MemberInfo.GetMemberInfoType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetMemberInfoType方法的具体用法?C# MemberInfo.GetMemberInfoType怎么用?C# MemberInfo.GetMemberInfoType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.GetMemberInfoType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetToDbConverter
public virtual Func<object, object> GetToDbConverter(Type destType, MemberInfo sourceMemberInfo)
{
var type = sourceMemberInfo.GetMemberInfoType();
return sourceMemberInfo != null ? GetToDbConverter(destType, type) : null;
}
示例2: GetFromDbConverter
public virtual Func<object, object> GetFromDbConverter(MemberInfo destMemberInfo, Type sourceType)
{
var type = destMemberInfo.GetMemberInfoType();
return destMemberInfo != null ? GetFromDbConverter(type, sourceType) : null;
}
示例3: IsList
public static bool IsList(MemberInfo mi)
{
return mi.GetMemberInfoType().IsOfGenericType(typeof(IList<>)) && !mi.GetMemberInfoType().IsArray;
}
示例4: FromMemberInfo
public static ColumnInfo FromMemberInfo(MemberInfo mi)
{
var ci = new ColumnInfo{MemberInfo = mi};
var attrs = ReflectionUtils.GetCustomAttributes(mi);
var colAttrs = attrs.OfType<ColumnAttribute>();
var columnTypeAttrs = attrs.OfType<ColumnTypeAttribute>();
var ignoreAttrs = attrs.OfType<IgnoreAttribute>();
var complexMapping = attrs.OfType<ComplexMappingAttribute>();
var serializedColumnAttributes = attrs.OfType<SerializedColumnAttribute>();
var reference = attrs.OfType<ReferenceAttribute>();
var aliasColumn = attrs.OfType<AliasAttribute>().FirstOrDefault();
// Check if declaring poco has [ExplicitColumns] attribute
var explicitColumns = mi.DeclaringType.GetTypeInfo().GetCustomAttributes(typeof(ExplicitColumnsAttribute), true).Any();
// Ignore column if declarying poco has [ExplicitColumns] attribute
// and property doesn't have an explicit [Column] attribute,
// or property has an [Ignore] attribute
if ((explicitColumns && !colAttrs.Any() && !reference.Any() && !complexMapping.Any()) || ignoreAttrs.Any())
{
ci.IgnoreColumn = true;
}
if (complexMapping.Any())
{
ci.ComplexMapping = true;
ci.ComplexPrefix = complexMapping.First().CustomPrefix;
}
else if (serializedColumnAttributes.Any())
{
ci.SerializedColumn = true;
}
else if (reference.Any())
{
ci.ReferenceType = reference.First().ReferenceType;
ci.ReferenceMemberName = reference.First().ReferenceMemberName ?? "Id";
ci.ColumnName = reference.First().ColumnName ?? mi.Name + "Id";
return ci;
}
else if (PocoDataBuilder.IsList(mi))
{
ci.ReferenceType = ReferenceType.Many;
return ci;
}
else if (mi.GetMemberInfoType().IsAClass() && !colAttrs.Any())
{
ci.ComplexMapping = true;
}
// Read attribute
if (colAttrs.Any())
{
var colattr = colAttrs.First();
ci.ColumnName = colattr.Name ?? mi.Name;
ci.ForceToUtc = colattr.ForceToUtc;
ci.ResultColumn = colattr is ResultColumnAttribute;
ci.VersionColumn = colattr is VersionColumnAttribute;
ci.VersionColumnType = ci.VersionColumn ? ((VersionColumnAttribute) colattr).VersionColumnType : ci.VersionColumnType;
ci.ComputedColumn = colattr is ComputedColumnAttribute;
ci.ComputedColumnType = ci.ComputedColumn ? ((ComputedColumnAttribute)colattr).ComputedColumnType : ComputedColumnType.Always;
}
else
{
ci.ColumnName = mi.Name;
}
ci.ColumnAlias = aliasColumn != null ? aliasColumn.Alias : null;
if (columnTypeAttrs.Any())
{
ci.ColumnType = columnTypeAttrs.First().Type;
}
return ci;
}
示例5: GetFromDbConverter
public virtual Func<object, object> GetFromDbConverter(MemberInfo mi, Type SourceType)
{
var t = mi.GetMemberInfoType();
return mi != null ? GetFromDbConverter(t, SourceType) : null;
}