private static bool HasUnconditionalDerivedTargetTypeMapping( IEnumerable <DerivedTypePair> derivedTypePairs, IMemberMapperData declaredTypeMapperData, out Type unconditionalDerivedTargetType, out TypePairGroup[] groupedTypePairs) { groupedTypePairs = derivedTypePairs .GroupBy(tp => tp.DerivedTargetType) .Project(group => new TypePairGroup(group)) .OrderBy(tp => tp.DerivedTargetType, MostToLeastDerived) .ToArray(); var unconditionalTypePairs = groupedTypePairs .Filter(tpg => tpg.TypePairs.None(tp => tp.HasConfiguredCondition)); foreach (var unconditionalTypePair in unconditionalTypePairs) { var typePairsCondition = declaredTypeMapperData .GetTargetValidCheckOrNull(unconditionalTypePair.DerivedTargetType); if (typePairsCondition == null) { unconditionalDerivedTargetType = unconditionalTypePair.DerivedTargetType; return(true); } } unconditionalDerivedTargetType = null; return(false); }
private static Expression GetTypePairCondition(DerivedTypePair derivedTypePair, IMemberMapperData declaredTypeMapperData) { var condition = declaredTypeMapperData.GetTargetValidCheckOrNull(derivedTypePair.DerivedTargetType); if (!derivedTypePair.HasConfiguredCondition) { return(condition); } var pairCondition = derivedTypePair.GetConditionOrNull(declaredTypeMapperData); return((condition != null) ? AndAlso(pairCondition, condition) : pairCondition); }
private static Expression AppendTargetValidCheckIfAppropriate( Expression condition, Type targetType, IMemberMapperData mapperData) { if (targetType == mapperData.TargetType) { return(condition); } var targetIsValid = mapperData.GetTargetValidCheckOrNull(targetType); if (targetIsValid == null) { return(condition); } condition = AndAlso(condition, targetIsValid); return(condition); }