Class PropertyInfoExtension

Reflection helper class that allows to directly set values in properties.

Inheritance
System.Object
PropertyInfoExtension
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ETLBox.Helper
Assembly: ETLBox.dll
Syntax
    public static class PropertyInfoExtension

Methods

SetValueOrThrow(PropertyInfo, Object, Object)

Sets a value in a property. If this is not possible, this method throws an exception.

Declaration
    public static void SetValueOrThrow(this PropertyInfo pi, object obj, object value)
Parameters
TypeNameDescription
System.Reflection.PropertyInfopi

The property info for the property

System.Objectobj

The object that contains the property

System.Objectvalue

The new value for the property

TrySetValue(PropertyInfo, Object, Object, Type)

Tries to set a value in a property. If not possible, it will do nothing.

Declaration
    public static void TrySetValue(this PropertyInfo pi, object obj, object value, Type enumType = null)
Parameters
TypeNameDescription
System.Reflection.PropertyInfopi

The property info for the property

System.Objectobj

The object that contains the property

System.Objectvalue

The new value for the property

System.TypeenumType

If the property is an enum type, this will need special handling - pass the enum type here. Default value is null.