feat: PropertyInfo extensions in 2008 to mimic overloads in NetStandard

This commit is contained in:
Drew Tingen
2020-07-14 14:07:17 -04:00
parent e093a57172
commit 67445de8b9

View File

@@ -129,6 +129,38 @@ namespace ICD.Common.Utils.Extensions
} }
#endif #endif
#if SIMPLSHARP
/// <summary>
/// Returns the value of the property
/// Only needed for SIMPLSHARP since newer .Net contains this already
/// </summary>
/// <param name="extends"></param>
/// <param name="obj"></param>
/// <returns>The property value for the obj parameter.</returns>
public static object GetValue([NotNull] this PropertyInfo extends, object obj)
{
if (extends == null)
throw new ArgumentNullException("extends");
return extends.GetValue(obj, null);
}
/// <summary>
/// Sets the value of the property
/// Only needed for SIMPLSHARP since newer .Net contains this already
/// </summary>
/// <param name="extends"></param>
/// <param name="obj"></param>
/// <param name="value"></param>
public static void SetValue([NotNull] this PropertyInfo extends, object obj, object value)
{
if (extends == null)
throw new ArgumentNullException("extends");
extends.SetValue(obj, value, null);
}
#endif
/// <summary> /// <summary>
/// Sets the value of a property /// Sets the value of a property
/// Traverses the path to access properties nested in other properties /// Traverses the path to access properties nested in other properties