public RecordMap(Type type, RecordAttribute recordAttribute, RecordTypeAttribute recordTypeAttribute, IDictionary<int, FieldMap> basicFieldMaps, IList<FieldMap> advancedFieldMaps, IList<IndexMap> indexMaps, IList<LinkRecord> linkRecords) { this.type = type; this.recordAttribute = recordAttribute; this.recordTypeAttribute = recordTypeAttribute; this.basicFieldMaps = basicFieldMaps; this.advancedFieldMaps = advancedFieldMaps; this.indexMaps = indexMaps; this.linkRecords = linkRecords; }
public RecordMap(Type type, RecordAttribute recordAttribute, RecordTypeAttribute recordTypeAttribute, IDictionary <int, FieldMap> basicFieldMaps, IList <FieldMap> advancedFieldMaps, IList <IndexMap> indexMaps, IList <LinkRecord> linkRecords) { this.type = type; this.recordAttribute = recordAttribute; this.recordTypeAttribute = recordTypeAttribute; this.basicFieldMaps = basicFieldMaps; this.advancedFieldMaps = advancedFieldMaps; this.indexMaps = indexMaps; this.linkRecords = linkRecords; }
public RecordTypeAttribute GetRecordTypeAttribute(Type type) { RecordTypeAttribute recordTypeAttribute = null; foreach (Attribute attribute in type.GetCustomAttributes(typeof(RecordTypeAttribute), false)) { recordTypeAttribute = (RecordTypeAttribute)attribute; break; } return(recordTypeAttribute); }
public RecordMap GetRecordMap(Type type) { RecordTypeAttribute attribute = GetRecordTypeAttribute(type); if (attribute != null) { if (attribute.IsProxy) { return(ProxyRecordMaps[attribute.ProxyType]); } //GetRecordMap(attribute.ProxyType); else { return(RecordMaps[attribute.Id]); } } else { return(null); } }
private RecordMap GetRecordMap(Type type, RecordAttribute recordAttribute) { RecordMap recordMap = null; RecordTypeAttribute recordTypeAttribute = GetRecordTypeAttribute(type); if (recordTypeAttribute != null) { IDictionary <int, FieldMap> basicFieldMaps = new Dictionary <int, FieldMap>(); IList <FieldMap> advancedFieldMaps = new List <FieldMap>(); IList <IndexMap> indexMaps = new List <IndexMap>(); IList <LinkRecord> linkRecords = new List <LinkRecord>(); foreach (PropertyInfo property in type.GetProperties()) { foreach (Attribute attribute in property.GetCustomAttributes(typeof(FieldAttribute), true)) { FieldAttribute fieldAttribute = (FieldAttribute)attribute; FieldMap fieldMap = new FieldMap(fieldAttribute, property); if (fieldAttribute.Location == FieldLocation.Local) { basicFieldMaps.Add(fieldAttribute.Ordinal, fieldMap); } else if (fieldAttribute.Location == FieldLocation.Foreign) { advancedFieldMaps.Add(fieldMap); if (!string.IsNullOrEmpty(fieldAttribute.ForeignParentFieldName)) { linkRecords.Add(new LinkRecord(fieldAttribute.ForeignRecordName, fieldAttribute.ForeignParentFieldName, fieldAttribute.ForeignChildFieldName, fieldMap)); } } } foreach (IndexAttribute attribute in property.GetCustomAttributes(typeof(IndexAttribute), true)) { IndexMap indexMap = new IndexMap(attribute, property); indexMaps.Add(indexMap); } } foreach (Type interfaceType in type.GetInterfaces()) { foreach (PropertyInfo interfaceProperty in interfaceType.GetProperties()) { foreach (FieldAttribute attribute in interfaceProperty.GetCustomAttributes(typeof(FieldAttribute), true)) { FieldMap fieldMap = new FieldMap(attribute, interfaceProperty); if (attribute.Location == FieldLocation.Local) { basicFieldMaps.Add(attribute.Ordinal, fieldMap); } else if (attribute.Location == FieldLocation.Foreign) { advancedFieldMaps.Add(fieldMap); if (!string.IsNullOrEmpty(attribute.ForeignParentFieldName)) { linkRecords.Add(new LinkRecord(attribute.ForeignRecordName, attribute.ForeignParentFieldName, attribute.ForeignChildFieldName, fieldMap)); } } } foreach (IndexAttribute attribute in interfaceProperty.GetCustomAttributes(typeof(IndexAttribute), true)) { IndexMap indexMap = new IndexMap(attribute, interfaceProperty); indexMaps.Add(indexMap); } } } recordMap = new RecordMap(type, recordAttribute, recordTypeAttribute, basicFieldMaps, advancedFieldMaps, indexMaps, linkRecords); } return(recordMap); }