public void Contribute(MappingStrategy strategy) { var sourceProperties = strategy.Source.GetProperties(); foreach (var targetProperty in strategy.Target.GetProperties()) { var sourcePropertyChain = BuildPropertyChain(targetProperty.Name, sourceProperties); if (sourcePropertyChain.Length > 1) { strategy.AddMappingStep(new AssignChain(targetProperty, sourcePropertyChain)); } } foreach (var mappingStep in strategy.ConstructorParameterMappingSteps.ByKey) { if (mappingStep.Value == null) { var targetParameter = mappingStep.Key; var sourcePropertyChain = BuildPropertyChain(targetParameter.Name, sourceProperties); if (sourcePropertyChain.Length > 1) { mappingStep.UpdateValue(new ConstructorAssignChain(mappingStep.Key, sourcePropertyChain)); } } } }
public void Contribute(MappingStrategy strategy) { var properties = strategy.Source.GetProperties(); foreach (var targetProperty in strategy.Target.GetProperties()) { var sourceProperty = Array.Find(properties, p => p.Name == targetProperty.Name); if (sourceProperty != null) { var assign = new Assign(targetProperty, sourceProperty); strategy.AddMappingStep(assign); } } foreach (var mappingStep in strategy.ConstructorParameterMappingSteps.ByKey) { if (mappingStep.Value == null) { var sourceProperty = Array.Find(properties, p => string.Equals(p.Name, mappingStep.Key.Name, StringComparison.OrdinalIgnoreCase)); if (sourceProperty != null) { var assign = new ConstructorAssign(mappingStep.Key, sourceProperty); mappingStep.UpdateValue(assign); } } } }
public void Contribute(MappingStrategy strategy) { foreach (var targetProperty in strategy.Target.GetProperties().Where(p => p.Name.EndsWith(targetPropertyNameSuffix, StringComparison.OrdinalIgnoreCase))) { var expectedName = GetExpectedName(targetProperty); var sourceProperty = strategy.Source.GetProperties().FirstOrDefault(p => p.Name == expectedName); if (sourceProperty != null) { var assign = new Assign(targetProperty, sourceProperty); strategy.AddMappingStep(assign); } } }