예제 #1
0
        private static void GetTypeInfo(Type type, out Dictionary <string, PropertyDataBindingInfo> dataMappingInfos,
                                        out List <ReferencedTypeBindingInfo> referObjs,
                                        out Dictionary <string, DataMappingAttribute> propertyInfos)
        {
            PropertyInfo[] propertyList = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            dataMappingInfos = new Dictionary <string, PropertyDataBindingInfo>();
            referObjs        = new List <ReferencedTypeBindingInfo>();
            propertyInfos    = new Dictionary <string, DataMappingAttribute>(new CaseInsensitiveStringEqualityComparer());

            foreach (PropertyInfo propertyInfo in propertyList)
            {
                //获取所有的特性
                Object[] attributes = propertyInfo.GetCustomAttributes(false);
                foreach (Object attribute in attributes)
                {
                    // 处理简单类型
                    if (attribute is DataMappingAttribute)
                    {
                        DataMappingAttribute obj = attribute as DataMappingAttribute;
                        dataMappingInfos[obj.ColumnName.ToUpper()] = new PropertyDataBindingInfo(obj, propertyInfo);

                        propertyInfos.Add(propertyInfo.Name, obj);
                        continue;
                    }

                    // 处理复杂类型
                    if (attribute is ReferencedEntityAttribute)
                    {
                        ReferencedEntityAttribute obj = attribute as ReferencedEntityAttribute;
                        referObjs.Add(new ReferencedTypeBindingInfo(obj, propertyInfo));
                    }
                }
            }
        }
예제 #2
0
 public PropertyDataBindingInfo(DataMappingAttribute mapping, PropertyInfo propertyInfo)
 {
     DataMapping  = mapping;
     PropertyInfo = propertyInfo;
 }