Esempio n. 1
0
 protected override object DoConvert(object source, object target = null)
 {
     foreach (var mapRules in Rule.Parent.GetRule(source.GetType(), target.GetType()).Fields)
     {
         EnsurePropertyInfoCache(mapRules, source.GetType(), target.GetType());
         var innPropValue = mapRules.Value.GetExpression(source);
         var outPropValue = ConverterFactory.Convert(mapRules, innPropValue);
         mapRules.Value.SetExpression(target, outPropValue);
     }
     return(target);
 }
Esempio n. 2
0
 private void ConvertProperty(object source, KeyValuePair <string, IMapRules> mapRules, object newtarget)
 {
     try
     {
         EnsurePropertyInfoCache(source, mapRules);
         var outPropValue = ConverterFactory.Convert(mapRules, GetInValue(source, mapRules), this.UpdateParentTarget(mapRules)? newtarget:null);
         if (mapRules.Value.OutPropertyInfo.IsInstance() && outPropValue != null)
         {
             mapRules.Value.SetExpression(newtarget, outPropValue);
         }
     }
     catch (Exception ex)
     {
         throw new InvalidCastException(string.Format("Unable to convert {0} to {1}", mapRules.Key, mapRules.Value.OutMemberName), ex);
     }
 }