예제 #1
0
            private static void FilterOutConfiguredPairs(
                ICollection <string> unmatchedSourceValues,
                Type sourceEnumType,
                Type targetEnumType,
                IMapperContextOwner mapperContextOwner)
            {
                var relevantEnumPairings = mapperContextOwner
                                           .MapperContext
                                           .UserConfigurations
                                           .GetEnumPairingsFor(sourceEnumType, targetEnumType);

                foreach (var enumParing in relevantEnumPairings)
                {
                    if (unmatchedSourceValues.Contains(enumParing.PairingEnumMemberName))
                    {
                        unmatchedSourceValues.Remove(enumParing.PairingEnumMemberName);
                    }
                }
            }
예제 #2
0
            private static string[] GetMappingMismatches(
                Type sourceEnumType,
                Type targetEnumType,
                IEnumerable <string> targetEnumNames,
                IMapperContextOwner mapperContextOwner)
            {
                var sourceEnumNames       = Enum.GetNames(sourceEnumType);
                var unmatchedSourceValues = sourceEnumNames.Except(targetEnumNames).ToList();

                if (unmatchedSourceValues.Any())
                {
                    FilterOutConfiguredPairs(unmatchedSourceValues, sourceEnumType, targetEnumType, mapperContextOwner);
                }

                if (unmatchedSourceValues.None())
                {
                    return(Enumerable <string> .EmptyArray);
                }

                var mismatches = unmatchedSourceValues
                                 .ProjectToArray(value => $" - {sourceEnumType.Name}.{value} matches no {targetEnumType.Name}");

                return(mismatches);
            }
 private static bool HasConfiguredSimpleTypeValueFactories(this IMapperContextOwner mapperContextOwner)
 => mapperContextOwner.MapperContext.UserConfigurations.HasSimpleTypeValueFactories;
예제 #4
0
 private static Member[] GetConfiguredMemberChainOrNull(Expression value, IMapperContextOwner contextOwner)
 => value.ToSourceMemberOrNull(contextOwner.MapperContext)?.MemberChain;