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));
        }
示例#2
0
            public bool Equals(EnumMappingMismatch other)
            {
                if (ReferenceEquals(other, this))
                {
                    return(true);
                }

                return(false);
            }
示例#3
0
        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);
        }