/// <summary> /// Applies configuration to the given <see cref="MemberMap" />. /// </summary> /// <param name="referenceMap">The reference map.</param> /// <exception cref="NotImplementedException"></exception> public void ApplyTo(MemberReferenceMap referenceMap) { foreach (var memberMap in referenceMap.Data.Mapping.MemberMaps) { ApplyTo(memberMap); } }
public MetadataFilteredMap(ExportedTypePropertyInfo[] includedProperties) { var exportedType = typeof(T); var includedPropertiesInfo = includedProperties ?? exportedType.GetPropertyNames().PropertyInfos; var columnIndex = 0; foreach (var includedPropertyInfo in includedPropertiesInfo) { var propertyNames = includedPropertyInfo.FullName.Split('.'); var currentType = exportedType; ClassMap currentClassMap = this; for (int i = 0; i < propertyNames.Length; i++) { var propertyName = propertyNames[i]; var propertyInfo = currentType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance); if (propertyInfo?.CanRead != true) { break; } // Do not write enumerables (ICollection, etc.) if (IsEnumerableEntityProperty(propertyInfo)) { break; } // Add memberMap if (i == propertyNames.Length - 1) { var memberMap = CreateMemberMap(currentType, propertyInfo, includedPropertyInfo.DisplayName, ref columnIndex); currentClassMap.MemberMaps.Add(memberMap); currentClassMap = this; } // Working with nested properties - create or get References else { var referenceMap = currentClassMap.ReferenceMaps.Find(propertyInfo); currentType = propertyInfo.PropertyType; if (referenceMap == null) { var referenceClassMapType = typeof(EmptyClassMapImpl <>).MakeGenericType(new[] { currentType }); referenceMap = new MemberReferenceMap(propertyInfo, (ClassMap)Activator.CreateInstance(referenceClassMapType)); currentClassMap.ReferenceMaps.Add(referenceMap); } currentClassMap = referenceMap.Data.Mapping; } } } }
/// <summary> /// Applies configuration to the given <see cref="MemberMap" />. /// </summary> /// <param name="referenceMap">The reference map.</param> public void ApplyTo(MemberReferenceMap referenceMap) { referenceMap.Data.Prefix = Prefix ?? referenceMap.Data.Member.Name + "."; }