当前位置: 首页>>代码示例>>C#>>正文


C# PropertyInfo.GetType方法代码示例

本文整理汇总了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;
        }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:9,代码来源:DCTWordObjectBuilder.cs

示例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;
        }
开发者ID:data-avail,项目名称:DataAvail.Framework,代码行数:23,代码来源:TypeMap.cs

示例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);
            }
        }
开发者ID:ahmedelbaradey,项目名称:DirigoEdge,代码行数:20,代码来源:TimeUtils.cs

示例4: FromPropertyInfo

 internal static Parameter FromPropertyInfo(PropertyInfo propertyInfo, object instance)
 {
     return new Parameter(propertyInfo.GetType(), propertyInfo.PropertyType, propertyInfo.Name, propertyInfo.GetValue(instance, null));
 }
开发者ID:blazey,项目名称:blazey.micro,代码行数:4,代码来源:Parameter.cs

示例5: AddPropertyChildren

		protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
		{
			AddSubnodes (c, parent, pi.GetType(), pi);
		}
开发者ID:emtees,项目名称:old-code,代码行数:4,代码来源:ReflectionNodeFinder.cs

示例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;
            }
        }
开发者ID:huoxudong125,项目名称:WCFLoadUI,代码行数:52,代码来源:ControlsHelper.cs

示例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;
 }
开发者ID:perryofpeek,项目名称:SqlToGraphite-core,代码行数:13,代码来源:BuilderBase.cs

示例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;
 }
开发者ID:perryofpeek,项目名称:SqlToGraphite-core,代码行数:13,代码来源:BuilderBase.cs


注:本文中的System.Reflection.PropertyInfo.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。