public static EnumMappingMismatchSet For( QualifiedMember targetMember, IEnumerable <IDataSource> dataSources, IMemberMapperData mapperData) { var sourceEnumData = dataSources .Select(ds => new { DataSource = ds, EnumType = ds.SourceMember.Type.GetNonNullableType() }) .GroupBy(dss => dss.EnumType) .Select(dsGroup => new { EnumType = dsGroup.Key, SourceMembers = dsGroup.Select(ds => ds.DataSource.SourceMember).ToArray() }) .ToArray(); var targetEnumType = targetMember.Type.GetNonNullableType(); var targetEnumNames = Enum.GetNames(targetEnumType); var mappingMismatches = sourceEnumData .Where(d => d.EnumType != targetEnumType) .Select(d => EnumMappingMismatch.For( d.EnumType, d.SourceMembers, targetEnumType, targetEnumNames, targetMember, mapperData)) .ToArray(); return(new EnumMappingMismatchSet(mappingMismatches)); }
public bool Equals(EnumMappingMismatch other) { if (ReferenceEquals(other, this)) { return(true); } return(false); }
public static EnumMappingMismatchSet For( QualifiedMember targetMember, IEnumerable <IDataSource> dataSources, IMemberMapperData mapperData) { var sourceEnumData = dataSources .Project(ds => new { DataSource = ds, EnumType = ds.SourceMember.Type.GetNonNullableType() }) .GroupBy(dss => dss.EnumType) .Project(dsGroup => new { EnumType = dsGroup.Key, SourceMembers = dsGroup.Project(ds => ds.DataSource.SourceMember).ToArray() }) .ToArray(); var targetEnumType = targetMember.Type.GetNonNullableType(); var targetEnumNames = Enum.GetNames(targetEnumType); var mappingMismatches = sourceEnumData .Filter(targetEnumType, (tet, d) => d.EnumType != tet) .Project(d => EnumMappingMismatch.For( d.EnumType, d.SourceMembers, targetEnumType, targetEnumNames, targetMember, mapperData)) .Filter(mm => mm.Any) .ToArray(); return(mappingMismatches.Any() ? new EnumMappingMismatchSet(mappingMismatches) : _emptySet); }