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


C# MemberInfo.GetGetter方法代码示例

本文整理汇总了C#中System.Reflection.MemberInfo.GetGetter方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetGetter方法的具体用法?C# MemberInfo.GetGetter怎么用?C# MemberInfo.GetGetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.GetGetter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MemberMapping

        internal MemberMapping(MemberInfo member, MemberAttribute attribute, EntityMapping entity)
        {
            this.member = member;
            this.entity = entity;

            memberType = member.GetMemberType();
            var isEnumerableType = memberType != Types.String
                && memberType != typeof(byte[])
                && Types.IEnumerable.IsAssignableFrom(memberType);

            if (attribute == null)
            {
                InitializeConversionMapping(isEnumerableType);
            }
            else
                InitializeAttributeMapping(attribute, isEnumerableType);

            getter = member.GetGetter();
            if (storageMember != null)
                setter = storageMember.GetSetter();
            else
                setter = member.GetSetter();
            if (columnName == null)
                columnName = member.Name;
        }
开发者ID:jaykizhou,项目名称:elinq,代码行数:25,代码来源:MemberMapping.cs

示例2: ColumnModel

            public ColumnModel(MemberInfo member)
            {
                MemberType = member.GetMemberType();
                var sourceType  = MemberType;
                AllowDBNull = sourceType.IsNullable();

                if (!AllowDBNull)
                {
                    IsEnum = sourceType.IsEnum;
                    if (IsEnum)
                        DataType = Enum.GetUnderlyingType(sourceType);
                    else
                        DataType = sourceType;
                }
                else
                {
                    sourceType =  Nullable.GetUnderlyingType(sourceType);
                    IsEnum = sourceType.IsEnum;
                    if (IsEnum)
                        DataType = Enum.GetUnderlyingType(sourceType);
                    else
                        DataType = sourceType;
                }
                ColumnName = member.Name;

                
                var getter = member.GetGetter();
                if (AllowDBNull)
                {
                    var p = MemberType.GetProperty("Value");

                    if (IsEnum)
                    {
                        SetColumnValue = (entity, row) =>
                        {
                            var v = getter(entity);
                            if (v == null)
                                row[ColumnName] = DBNull.Value;
                            else
                                row[ColumnName] = Converter.Convert(p.GetValue(v, null), DataType);
                        };
                    }
                    else
                    {
                        SetColumnValue = (entity, row) =>
                        {
                            var v = getter(entity);
                            if (v == null)
                                row[ColumnName] = DBNull.Value;
                            else
                                row[ColumnName] = p.GetValue(v, null);
                        };
                    }
                   
                }
                else
                {
                    if (DataType == Types.String)
                    {
                        AllowDBNull = true;
                        SetColumnValue = (entity, row) =>
                        {
                            var v = getter(entity);
                            row[ColumnName] = v == null ? DBNull.Value : v;
                        };
                    }
                    else
                    {
                        if(IsEnum)
                            SetColumnValue = (entity, row) => row[ColumnName] = Converter.Convert(getter(entity),DataType);
                        else
                            SetColumnValue = (entity, row) => row[ColumnName] = getter(entity);
                    }
                }
            }
开发者ID:netcasewqs,项目名称:nlite,代码行数:75,代码来源:DataTableMapper.cs


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