private Expression GetPopulationExpression() { var finalValue = _dataSources.GetFinalValueOrNull(); var excludeFinalValue = finalValue == null; var finalDataSourceIndex = _dataSources.Count - 1; Expression population = null; for (var i = finalDataSourceIndex; i >= 0; --i) { var dataSource = _dataSources[i]; if (i == finalDataSourceIndex) { if (excludeFinalValue) { continue; } population = MapperData.GetTargetMemberPopulation(finalValue); population = dataSource.FinalisePopulation(population); continue; } var memberPopulation = MapperData.GetTargetMemberPopulation(dataSource.Value); population = dataSource.FinalisePopulation(memberPopulation, population); } return(population); }
private Expression GetBinding(Expression populationGuard) { var bindingValue = _dataSources.BuildValue(); if (MapperData.RuleSet.Settings.AllowGuardedBindings && (populationGuard != null)) { bindingValue = bindingValue.ToIfFalseDefaultCondition(populationGuard, MapperData); } return(MapperData.GetTargetMemberPopulation(bindingValue)); }
public Expression GetPopulationExpression() { var fallbackValue = GetFallbackValueOrNull(); var excludeFallback = fallbackValue == null; Expression population = null; for (var i = _dataSources.Count - 1; i >= 0; --i) { var dataSource = _dataSources[i]; if (i == _dataSources.Count - 1) { if (excludeFallback) { continue; } population = MapperData.GetTargetMemberPopulation(fallbackValue); if (dataSource.IsConditional) { population = dataSource.AddCondition(population); } population = dataSource.AddPreCondition(population); continue; } var memberPopulation = MapperData.GetTargetMemberPopulation(dataSource.Value); population = dataSource.AddCondition(memberPopulation, population); population = dataSource.AddPreCondition(population); } return(population); }