Beispiel #1
0
 /// <summary>
 /// Try to get the value of the specified property name from the that.<br />
 /// 尝试从对象中获取指定属性名称的值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="value"></param>
 /// <param name="propertyValueGetter"></param>
 /// <returns></returns>
 public static bool TryGetPropertyValue(object that, string propertyName, BindingFlags bindingAttr, out object value, IPropertyValueGetter propertyValueGetter)
 {
     return(Try.Create(() => propertyValueGetter
                       .SafeRefValue(DefaultPropertyValueGetter.Instance)
                       .Invoke(that.GetType(), that, propertyName, bindingAttr))
            .GetSafeValueOut(out value, defaultVal: null)
            .IsSuccess);
 }
Beispiel #2
0
 /// <summary>
 /// Try to get the value of the specified property name from the that.<br />
 /// 尝试从对象中获取指定属性名称的值。
 /// </summary>
 /// <param name="that">Any <see cref="object"/></param>
 /// <param name="propertyName">Property name in this that</param>
 /// <param name="propertyValueGetter"></param>
 /// <param name="value"></param>
 /// <returns>Value of the specific property in this that</returns>
 public static bool TryGetPropertyValue <TVal>(object that, string propertyName, IPropertyValueGetter propertyValueGetter, out TVal value)
 {
     return(Try.Create(() => propertyValueGetter
                       .SafeRefValue(DefaultPropertyValueGetter.Instance)
                       .Invoke(that.GetType(), that, propertyName)
                       .As <TVal>())
            .GetSafeValueOut(out value, defaultVal: default)
            .IsSuccess);
 }
Beispiel #3
0
 /// <summary>
 /// Get the value of the specified property name from the that.<br />
 /// 从对象中获取指定属性名称的值。
 /// </summary>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <param name="propertyValueGetter"></param>
 /// <returns></returns>
 public static TVal GetPropertyValue <TVal>(object that, string propertyName, BindingFlags bindingAttr, IPropertyValueGetter propertyValueGetter)
 => propertyValueGetter.SafeRefValue(DefaultPropertyValueGetter.Instance).Invoke(that.GetType(), that, propertyName, bindingAttr).As <TVal>();
Beispiel #4
0
 /// <summary>
 /// Get the value of the specified property name from the that.<br />
 /// 从对象中获取指定属性名称的值。
 /// </summary>
 /// <param name="that">Any <see cref="object"/></param>
 /// <param name="propertyName">Property name in this that</param>
 /// <param name="propertyValueGetter"></param>
 /// <returns>Value of the specific property in this that</returns>
 public static object GetPropertyValue(object that, string propertyName, IPropertyValueGetter propertyValueGetter)
 => propertyValueGetter.SafeRefValue(DefaultPropertyValueGetter.Instance).Invoke(that.GetType(), that, propertyName);