Ejemplo n.º 1
0
 public void Copy(TTargetEntity fromEntity, TTargetEntity toEntity)
 {
     foreach (var fieldMapper in fieldMappers)
     {
         fieldMapper.Apply(fromEntity, toEntity);
     }
 }
Ejemplo n.º 2
0
            public KeyValuePair <string, string> Stringify(TSourceEntity source, TTargetEntity target)
            {
                Apply(source, target);

                var targetFieldString            = stringify(targetFieldFunc(target));
                var simplePropertyNameAggregator = new SimplePropertyNameAggregator();

                simplePropertyNameAggregator.Visit(targetField.Body, false);

                if (string.IsNullOrEmpty(tagVlaue))
                {
                    var error =
                        $"Can't stringify a field where tag value is not defined for source entity: {typeof(TSourceEntity).Name}, " +
                        $"target entity: {typeof(TTargetEntity).Name}";

                    throw new Exception(error);
                }

                var keyFormat = tagVlaue + ".{0}";
                var result    = new KeyValuePair <string, string>(
                    string.Format(keyFormat, simplePropertyNameAggregator.PropertyMetaData.PropertyInfoList[0].Name),
                    targetFieldString);

                return(result);
            }
Ejemplo n.º 3
0
            public TTargetEntity Convert(TSourceEntity sourceEntity)
            {
                var targetEntity = new TTargetEntity();

                foreach (var fieldMapper in fieldMappers)
                {
                    fieldMapper.Apply(sourceEntity, targetEntity);
                }

                return(targetEntity);
            }
Ejemplo n.º 4
0
            public Dictionary <string, string> Stringify(TSourceEntity sourceEntity)
            {
                var targetEntity = new TTargetEntity();
                var result       = new Dictionary <string, string>();

                foreach (var fieldMapper in fieldMappers)
                {
                    var pair = fieldMapper.Stringify(sourceEntity, targetEntity);
                    result.Add(pair.Key, pair.Value);
                }

                return(result);
            }
Ejemplo n.º 5
0
            public void Apply(TTargetEntity fromEntity, TTargetEntity toEntity)
            {
                var sourceValue = targetFieldFunc(fromEntity);

                targetFieldSetter(toEntity, sourceValue);
            }
Ejemplo n.º 6
0
            public void Apply(TSourceEntity source, TTargetEntity target)
            {
                var sourceValue = sourceFieldGetter(source);

                targetFieldSetter(target, sourceValue);
            }