private static Expression GetDerivedTypeMapping( DerivedSourceTypeCheck derivedSourceCheck, IObjectMappingData mappingData) { var mappingTryCatch = DerivedMappingFactory.GetDerivedTypeMapping( mappingData, derivedSourceCheck.TypedVariable, mappingData.MapperData.TargetType); return(mappingTryCatch); }
private static Expression GetReturnMappingResultExpression( IObjectMappingData declaredTypeMappingData, Expression sourceValue, Type targetType, out IObjectMappingData derivedTypeMappingData) { var mapping = DerivedMappingFactory.GetDerivedTypeMapping( declaredTypeMappingData, sourceValue, targetType, out derivedTypeMappingData); return((mapping != EmptyExpression) ? GetReturnMappingResultExpression(declaredTypeMappingData.MapperData, mapping) : mapping); }
private static void AddDeclaredSourceTypeDataSources( IEnumerable <DerivedTypePair> derivedTypePairs, IObjectMappingData declaredTypeMappingData, ICollection <IDataSource> derivedTypeDataSources) { var declaredTypeMapperData = declaredTypeMappingData.MapperData; derivedTypePairs = derivedTypePairs .OrderBy(tp => tp.DerivedSourceType, MostToLeastDerived); foreach (var derivedTypePair in derivedTypePairs) { var condition = GetTypePairCondition(derivedTypePair, declaredTypeMapperData); var sourceValue = GetDerivedTypeSourceValue( derivedTypePair, declaredTypeMappingData, out var sourceValueCondition); var derivedTypeMapping = DerivedMappingFactory.GetDerivedTypeMapping( declaredTypeMappingData, sourceValue, derivedTypePair.DerivedTargetType, out var derivedTypeMappingData); if (sourceValueCondition != null) { derivedTypeMapping = derivedTypeMapping.ToIfFalseDefaultCondition(sourceValueCondition); } var returnMappingResult = GetReturnMappingResultExpression(declaredTypeMapperData, derivedTypeMapping); var derivedTypeMappingDataSource = new DerivedComplexTypeDataSource( derivedTypeMappingData.MapperData.SourceMember, condition, returnMappingResult); derivedTypeDataSources.Add(derivedTypeMappingDataSource); if (!derivedTypeMappingDataSource.IsConditional) { return; } } }