Пример #1
0
 /// <summary>
 /// Adds a property to property
 /// mapping.
 /// </summary>
 /// <param name="sourceProperty">
 /// Name of source property.
 /// </param>
 /// <param name="targetProperty">
 /// Name of target property.
 /// </param>
 public void AddPropertyMapping(string sourceProperty, string targetProperty)
 {
     _map.Add(new MemberMapping(
                  MethodCaller.GetCachedProperty(_sourceType, sourceProperty),
                  MethodCaller.GetCachedProperty(_targetType, targetProperty)
                  ));
 }
Пример #2
0
        /// <summary>
        /// Sets an object's property with the specified value,
        /// coercing that value to the appropriate type if possible.
        /// </summary>
        /// <param name="target">Object containing the property to set.</param>
        /// <param name="propertyName">Name of the property to set.</param>
        /// <param name="value">Value to set into the property.</param>
        public static void SetPropertyValue(
            object target, string propertyName, object value)
        {
            DynamicMemberHandle handle = MethodCaller.GetCachedProperty(target.GetType(), propertyName);

            SetValueWithCoercion(target, handle, value);
        }