Exemplo n.º 1
0
        private static void SetValueWithCoercion(object target, DynamicMemberHandle handle, object value)
        {
            if (value == null)
            {
                return;
            }

            Type   pType = handle.MemberType;
            Type   vType = GetUnderlyingType(value.GetType());
            object v     = CoerceValue(pType, vType, value);

            if (v != null)
            {
                handle.DynamicMemberSet(target, v);
            }
        }
Exemplo n.º 2
0
        private static void SetValueWithCoercion(object target, DynamicMemberHandle handle, object value)
        {
            if (value == null)
                return;

            Type pType = handle.MemberType;
            Type vType = GetUnderlyingType(value.GetType());
            object v = CoerceValue(pType, vType, value);
            if (v != null)
                handle.DynamicMemberSet(target, v);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invokes a property setter using dynamic
        /// method invocation.
        /// </summary>
        /// <param name="obj">Target object.</param>
        /// <param name="property">Property to invoke.</param>
        /// <param name="value">New value for property.</param>
        public static void CallPropertySetter(object obj, string property, object value)
        {
            DynamicMemberHandle mh = GetCachedProperty(obj.GetType(), property);

            mh.DynamicMemberSet(obj, value);
        }