Пример #1
0
        public static Dictionary <string, MappingInfo> GetFieldMappings(Type type)
        {
            Dictionary <string, MappingInfo> dictionary = new Dictionary <string, MappingInfo>();

            foreach (PropertyInfo propertyInfo in type.GetProperties())
            {
                PropertyMappingAttribute propertyMappingAttribute = Attribute.GetCustomAttribute((MemberInfo)propertyInfo, typeof(PropertyMappingAttribute)) as PropertyMappingAttribute ?? new PropertyMappingAttribute(propertyInfo.Name);
                dictionary.Add(propertyMappingAttribute.Name, (MappingInfo) new PropertyMappingInfo(propertyMappingAttribute, propertyInfo));
            }
            foreach (FieldInfo fieldInfo in type.GetFields())
            {
                FieldMappingAttribute fieldMappingAttribute = Attribute.GetCustomAttribute((MemberInfo)fieldInfo, typeof(FieldMappingAttribute)) as FieldMappingAttribute ?? new FieldMappingAttribute(fieldInfo.Name);
                dictionary.Add(fieldMappingAttribute.Name, (MappingInfo) new FieldMappingInfo(fieldMappingAttribute, fieldInfo));
            }
            return(dictionary);
        }
Пример #2
0
 public FieldMappingInfo(FieldMappingAttribute fieldMappingAttribute, FieldInfo fieldInfo)
 {
     this.FieldMappingAttribute = fieldMappingAttribute;
     this.FieldInfo             = fieldInfo;
 }