コード例 #1
0
 /// <summary>
 /// Gets a property on the target object, as gotten from <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">the type to get the property from</typeparam>
 /// <typeparam name="U">the type of the property to get</typeparam>
 /// <param name="obj">the object instance</param>
 /// <param name="propertyName">the property to get</param>
 /// <returns>the value of the property</returns>
 /// <exception cref="MissingMemberException">if <paramref name="propertyName"/> does not exist on <typeparamref name="T"/></exception>
 /// <seealso cref="PropertyAccessor{T, U}.Get(ref T, string)"/>
 public static U GetProperty <U, T>(this T obj, string propertyName)
 => PropertyAccessor <T, U> .Get(ref obj, propertyName);
コード例 #2
0
 /// <summary>
 /// Sets a property on the target object, as gotten from <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">the type to get the property from</typeparam>
 /// <typeparam name="U">the type of the property to set</typeparam>
 /// <param name="obj">the object instance</param>
 /// <param name="propertyName">the property to set</param>
 /// <param name="value">the value to set it to</param>
 /// <exception cref="MissingMemberException">if <paramref name="propertyName"/> does not exist on <typeparamref name="T"/></exception>
 /// <seealso cref="PropertyAccessor{T, U}.Set(ref T, string, U)"/>
 public static void SetProperty <T, U>(this T obj, string propertyName, U value)
 => PropertyAccessor <T, U> .Set(ref obj, propertyName, value);