main
1using System;
2using System.Linq.Expressions;
3
4namespace MoMoney.boot.container.registration.mapping
5{
6 public class MappingStepFactory : IMappingStepFactory
7 {
8 readonly ITargetActionFactory target_action_factory;
9
10 public MappingStepFactory() : this(new TargetActionFactory())
11 {
12 }
13
14 public MappingStepFactory(ITargetActionFactory target_action_factory)
15 {
16 this.target_action_factory = target_action_factory;
17 }
18
19 public IMappingStep<Source, Destination> create_mapping_step_for<Source, Destination, PropertyType>(
20 Expression<Func<Source, PropertyType>> source_expression,
21 Expression<Func<Destination, PropertyType>> destination_expression)
22 {
23 var source_evaluator = new ExpressionSourceEvaluator<Source, PropertyType>(source_expression);
24
25 var target_action = target_action_factory.create_action_target_from(destination_expression);
26
27 return new MappingStep<Source, Destination, PropertyType>(source_evaluator, target_action);
28 }
29 }
30}