Class ReflectionHelper
Helps to get or set properties by reflection. Methods are taken from this post: http://dotnetfollower.com/wordpress/2012/12/c-how-to-set-or-get-value-of-a-private-or-internal-property-through-the-reflection/
Inheritance
System.Object
ReflectionHelper
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: OPTANO.Modeling.Optimization.Solver.Gurobi
Assembly: Optimization.Solver.Gurobi.dll
Syntax
public static class ReflectionHelper
Methods
GetFieldValue(Object, String)
Gets the value
for the specified fieldName
, using Reflection.
Declaration
public static object GetFieldValue(this object obj, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object. |
System.String | fieldName | The field name. |
Returns
Type | Description |
---|---|
System.Object | The property value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown, if |
System.ArgumentOutOfRangeException | Thrown, if |
SetFieldValue(Object, String, Object)
Sets the value
for the specified fieldName
to value
, using Reflection.
Declaration
public static void SetFieldValue(this object obj, string fieldName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object. |
System.String | fieldName | The field name. |
System.Object | value | The value to set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown, if |
System.ArgumentOutOfRangeException | Thrown, if |