mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: PropertyInfo extensions in 2008 to mimic overloads in NetStandard
This commit is contained in:
parent
e093a57172
commit
67445de8b9
1 changed files with 32 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue