本文整理汇总了C#中System.Reflection.PropertyInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.GetType方法的具体用法?C# PropertyInfo.GetType怎么用?C# PropertyInfo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToComplexProperty
private static DCTComplexProperty ConvertToComplexProperty(PropertyInfo propInfo, object source)
{
DCTComplexProperty complexProp = new DCTComplexProperty();
foreach (PropertyInfo item in propInfo.GetType().GetProperties())
{
}
return complexProp;
}
示例2: DefaultIfNullPropertyExpression
internal static Expression DefaultIfNullPropertyExpression(PropertyInfo SrcPropertyInfo, PropertyInfo DestPropertyInfo, MemberExpression ParameterExpression)
{
object def = null;
//TO DO: check PK property by attribute
if (SrcPropertyInfo.Name == "Id")
{
def = Mapper.KeyValueIfNullForReferneceProperties;
}
if (def == null && !Utils.Reflection.IsNullable(DestPropertyInfo.GetType()))
{
def = Utils.Reflection.GetDefault(DestPropertyInfo.PropertyType);
}
var expr = Expression.Condition(
Expression.NotEqual(ParameterExpression, Expression.Constant(null))
, Expression.Property(ParameterExpression, SrcPropertyInfo)
, Expression.Constant(def, DestPropertyInfo.PropertyType)
, DestPropertyInfo.PropertyType);
return expr;
}
示例3: ConvertDateList
private static void ConvertDateList(object obj, PropertyInfo prop, Func<DateTime, DateTime> convertFunction, Type listType, List<object> itemlist)
{
if (prop.GetType() != typeof(List<>))
{
// At this point I couldn't figure out a way to instantiate a new
// list/array/etc dynamically without a huge switch for each type.
// for now, we support lists and can other types as need be.
return;
}
if (listType == typeof(DateTime))
{
UpdateDateTimeList(obj, prop, convertFunction, itemlist);
}
if (listType == typeof(DateTime?))
{
UpdateNullableDateTimeList(obj, prop, convertFunction, itemlist);
}
}
示例4: FromPropertyInfo
internal static Parameter FromPropertyInfo(PropertyInfo propertyInfo, object instance)
{
return new Parameter(propertyInfo.GetType(), propertyInfo.PropertyType, propertyInfo.Name, propertyInfo.GetValue(instance, null));
}
示例5: AddPropertyChildren
protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
{
AddSubnodes (c, parent, pi.GetType(), pi);
}
示例6: GetPropertyDetails
private static ControlView GetPropertyDetails(PropertyInfo propertyInfo, string guid, ParamValue paramValue = null)
{
bool isNullableType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) != null;
if (
propertyInfo.PropertyType.Name.ToLower() == "dictionary`2"
&& propertyInfo.PropertyType.IsGenericType
&& propertyInfo.PropertyType.GenericTypeArguments != null
&& propertyInfo.PropertyType.GenericTypeArguments.Length == 2)
{
var newParamValues = GetNewParamValues(propertyInfo.Name, paramValue);
var arrayObject = GetTypeDetailsDictionaryObject(propertyInfo.PropertyType, propertyInfo.Name, newParamValues, guid);
return arrayObject;
}
//for list
else if (propertyInfo.PropertyType.IsArray)
{
int dimensions = propertyInfo.PropertyType.FullName.Split(new[] { "[]" }, StringSplitOptions.None).Length - 1;
Type arrayBaseType = propertyInfo.PropertyType.GetElementType();
for (int ii = 1; ii < dimensions; ii++)
{
arrayBaseType = arrayBaseType.GetElementType();
}
var newParamValues = GetNewParamValues(propertyInfo.Name, paramValue);
var arrayObject = GetTypeDetailsArrayObject(propertyInfo.Name, arrayBaseType, newParamValues, dimensions, guid);
return arrayObject;
}
else if (propertyInfo.PropertyType.IsPrimitive
|| propertyInfo.GetType().IsPrimitive
|| propertyInfo.PropertyType.Name.ToLower() == "string"
|| (isNullableType && PrimitiveTypes.Test(Nullable.GetUnderlyingType(propertyInfo.PropertyType)))
|| PrimitiveTypes.Test(propertyInfo.PropertyType)
)
{
string value = string.Empty;
if (paramValue != null)
{
value = paramValue.Param.ContainsKey(propertyInfo.Name) ? paramValue.Param[propertyInfo.Name] : string.Empty;
}
var cv = GetTypeDetailPrimitiveObject(propertyInfo.PropertyType, propertyInfo.Name, isNullableType, value, guid);
return cv;
}
else
{
var newParamValues = GetNewParamValues(propertyInfo.Name, paramValue);
ControlView cv1 = GetTypeDetailComplexObject(propertyInfo.PropertyType, guid, newParamValues, propertyInfo.Name);
return cv1;
}
}
示例7: IsEncrypted
private bool IsEncrypted(PropertyInfo property)
{
PropertyInfo[] properties = property.GetType().GetProperties();
foreach (PropertyInfo prop in properties)
{
var attribute = Attribute.GetCustomAttribute(property, typeof(EncryptedAttribute)) as EncryptedAttribute;
if (attribute != null)
{
return true;
}
}
return false;
}
示例8: GetHelp
private string GetHelp(PropertyInfo property)
{
PropertyInfo[] properties = property.GetType().GetProperties();
foreach (PropertyInfo prop in properties)
{
var attribute = Attribute.GetCustomAttribute(property, typeof(HelpAttribute)) as HelpAttribute;
if (attribute != null)
{
return attribute.Details;
}
}
return string.Empty;
}