Esempio n. 1
0
 /// <summary>
 /// Copies values from the source into the
 /// properties of the target.
 /// </summary>
 /// <param name="source">An object containing the source values.</param>
 /// <param name="target">An object with properties to be set from the dictionary.</param>
 /// <param name="suppressExceptions">If <see langword="true" />, any exceptions will be supressed.</param>
 /// <param name="map">A DataMap object containing the mappings to use during the copy process.</param>
 /// <remarks>
 /// The property names and types of the source object must match the property names and types
 /// on the target object. Source properties may not be indexed.
 /// Target properties may not be readonly or indexed.
 /// </remarks>
 public static void Map(object source, object target, DataMap map, bool suppressExceptions)
 {
     foreach (DataMap.MemberMapping mapping in map.GetMap())
     {
         try
         {
             object value = mapping.FromMemberHandle.DynamicMemberGet(source);
             SetValueWithCoercion(target, mapping.ToMemberHandle, value);
         }
         catch (Exception ex)
         {
             if (!suppressExceptions)
             {
                 throw new ArgumentException(
                           String.Format("{0} ({1})",
                                         Resources.PropertyCopyFailed, mapping.FromMemberHandle.MemberName), ex);
             }
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Copies values from the source into the
 /// properties of the target.
 /// </summary>
 /// <param name="source">An object containing the source values.</param>
 /// <param name="target">An object with properties to be set from the dictionary.</param>
 /// <param name="suppressExceptions">If <see langword="true" />, any exceptions will be supressed.</param>
 /// <param name="map">A DataMap object containing the mappings to use during the copy process.</param>
 /// <remarks>
 /// The property names and types of the source object must match the property names and types
 /// on the target object. Source properties may not be indexed. 
 /// Target properties may not be readonly or indexed.
 /// </remarks>
 public static void Map(object source, object target, DataMap map, bool suppressExceptions)
 {
   foreach (DataMap.MemberMapping mapping in map.GetMap())
   {
     try
     {
       object value = mapping.FromMemberHandle.DynamicMemberGet(source);
       SetValueWithCoercion(target, mapping.ToMemberHandle, value);
     }
     catch (Exception ex)
     {
       if (!suppressExceptions)
         throw new ArgumentException(
           String.Format("{0} ({1})",
           Resources.PropertyCopyFailed, mapping.FromMemberHandle.MemberName), ex);
     }
   }
 }
Esempio n. 3
0
 /// <summary>
 /// Copies values from the source into the
 /// properties of the target.
 /// </summary>
 /// <param name="source">An object containing the source values.</param>
 /// <param name="target">An object with properties to be set from the dictionary.</param>
 /// <param name="map">A DataMap object containing the mappings to use during the copy process.</param>
 /// <remarks>
 /// The property names and types of the source object must match the property names and types
 /// on the target object. Source properties may not be indexed. 
 /// Target properties may not be readonly or indexed.
 /// </remarks>
 public static void Map(object source, object target, DataMap map)
 {
   Map(source, target, map, false);
 }
Esempio n. 4
0
 /// <summary>
 /// Copies values from the source into the
 /// properties of the target.
 /// </summary>
 /// <param name="source">An object containing the source values.</param>
 /// <param name="target">An object with properties to be set from the dictionary.</param>
 /// <param name="map">A DataMap object containing the mappings to use during the copy process.</param>
 /// <remarks>
 /// The property names and types of the source object must match the property names and types
 /// on the target object. Source properties may not be indexed.
 /// Target properties may not be readonly or indexed.
 /// </remarks>
 public static void Map(object source, object target, DataMap map)
 {
     Map(source, target, map, false);
 }