本文整理汇总了C#中System.Reflection.MemberInfo.ReturnType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.ReturnType方法的具体用法?C# MemberInfo.ReturnType怎么用?C# MemberInfo.ReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.ReturnType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public static column Setup(this column column, MemberInfo memberInfo, string columnName = null, string columnPrefix = "", bool? notnull = true)
{
column.SetName(columnName ?? column.GetName() ?? memberInfo.Name.Sanitise(), columnPrefix);
if (memberInfo.ReturnType() == typeof(string))
{
var stringLengthAttribute = memberInfo.GetCustomAttributes(true).OfType<StringLengthAttribute>().SingleOrDefault();
string maxLength = stringLengthAttribute == null ? SqlDialect.Current.VarcharMax : stringLengthAttribute.MaximumLength.ToString();
column.sqltype = "NVARCHAR(" + maxLength + ")";
}
if (memberInfo.ReturnType() == typeof(byte[]))
{
column.sqltype = "VARBINARY(MAX)";
}
column.notnull = notnull;
return column;
}
示例2: _getSqlType
private static SqlColumnType _getSqlType(MemberInfo mi)
{
// See if there's any SqlTypeAttribute on the mi
// If so, pull the info from there.
var att = mi.GetCustomAttributes(typeof(SqlTypeAttribute), true)
.FirstOr(new SqlTypeAttribute()) as SqlTypeAttribute;
var baseType = SqlTypeConversion.GetSqlType(mi.ReturnType());
// For anything that's missing, get the assumed type info
var res = new SqlColumnType(
att.Type ?? baseType.SqlType,
att.IsNullable ?? baseType.IsNullable,
att.Length ?? baseType.Length,
att.Precision ?? baseType.Precision,
att.Scale ?? baseType.Scale);
return res;
}