Пример #1
0
 /// <summary>
 /// Try to set a value to the specified property name in the that.<br />
 /// 尝试向对象中的指定属性名称设置值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="value"></param>
 /// <param name="propertyValueSetter"></param>
 public static bool TrySetPropertyValue <T, TVal>(T that, string propertyName, BindingFlags bindingAttr, TVal value, IPropertyValueSetter propertyValueSetter)
 {
     return(Try.Invoke(() => propertyValueSetter
                       .SafeRefValue(DefaultPropertyValueSetter.Instance)
                       .Invoke(typeof(T), that, propertyName, bindingAttr, value))
            .IsSuccess);
 }
Пример #2
0
 /// <summary>
 /// Try to set a value to the specified property name in the that.<br />
 /// 尝试向对象中的指定属性名称设置值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="value"></param>
 /// <param name="propertyValueSetter"></param>
 public static bool TrySetPropertyValue(object that, string propertyName, BindingFlags bindingAttr, object value, IPropertyValueSetter propertyValueSetter)
 {
     return(Try.Invoke(() => propertyValueSetter
                       .SafeRefValue(DefaultPropertyValueSetter.Instance)
                       .Invoke(that.GetType(), that, propertyName, bindingAttr, value))
            .IsSuccess);
 }
Пример #3
0
 /// <summary>
 /// Set a value to the specified property name in the that.<br />
 /// 向对象中的指定属性名称设置值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="value"></param>
 /// <param name="propertyValueSetter"></param>
 public static void SetPropertyValue <T, TVal>(T that, string propertyName, BindingFlags bindingAttr, TVal value, IPropertyValueSetter propertyValueSetter)
 => propertyValueSetter.SafeRefValue(DefaultPropertyValueSetter.Instance).Invoke(typeof(T), that, propertyName, bindingAttr, value);
Пример #4
0
 /// <summary>
 /// Set a value to the specified property name in the that.<br />
 /// 向对象中的指定属性名称设置值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="value"></param>
 /// <param name="propertyValueSetter"></param>
 public static void SetPropertyValue(object that, string propertyName, BindingFlags bindingAttr, object value, IPropertyValueSetter propertyValueSetter)
 => propertyValueSetter.SafeRefValue(DefaultPropertyValueSetter.Instance).Invoke(that.GetType(), that, propertyName, bindingAttr, value);