Ejemplo n.º 1
0
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     const string name = "src";
     ParameterExpression source = Expression.Parameter(typeMap.SourceType, name);
     MemberAssignment[] bindings = typeMap.PropertyMaps
         .Select(m => m.BuildBind(source, configuration))
         .ToArray();
     return Expression.Lambda(
         Expression.Condition(Expression.Equal(source, Expression.Constant(null)),
                              Expression.Default(typeMap.DestinationType),
                              Expression.MemberInit(Expression.New(typeMap.DestinationType), bindings)), source);
 }
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     const string name = "src";
     ParameterExpression source = Expression.Parameter(typeMap.SourceType, name);
     ParameterExpression destination = Expression.Parameter(typeMap.DestinationType, "dst");
     Expression[] bindings = typeMap.PropertyMaps
         .Select(m => m.BuildAssign(destination, source, configuration))
         .Concat(new[] {destination})
         .ToArray();
     return Expression.Lambda(
         Expression.Block(bindings),
         source,
         destination);
 }
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     var tuple = Tuple.Create(typeMap.SourceType, typeMap.DestinationType);
     return concurrentDictionary.GetOrAdd(tuple, k => inner.Build(typeMap, configuration));
 }