Class ReflectionHelper
A helper class that provides the functionalities to retrieve information about assemblies, modules, members, parameters, and other entities in managed code.
Inheritance
Inherited Members
Namespace: Syncfusion.WinForms.Core.Utils
Assembly: Syncfusion.Core.WinForms.dll
Syntax
public static class ReflectionHelper
Methods
GetField(Type, String)
Searches for the specified field, using the specified binding constraints.
Declaration
public static FieldInfo GetField(Type type, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type used to get the field. |
System.String | fieldName | The string containing the name of the field to get. |
Returns
Type | Description |
---|---|
System.Reflection.FieldInfo | An object representing the field that matches the specified requirements, if found; otherwise, null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | name is null. |
GetMethod(Type, String)
Searches for the specified method, using the specified binding constraints.
Declaration
public static MethodInfo GetMethod(Type type, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type used to get the method. |
System.String | name | The string containing the name of the method to get. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | An object representing the method that matches the specified requirements, if found; otherwise, null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | name is null. |
GetMethod(Type, String, Int32)
Searches for the specified method, using the specified binding constraints.
Declaration
public static MethodInfo GetMethod(Type type, string name, int argumentsCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type used to get the method. |
System.String | name | The string containing the name of the method to get. |
System.Int32 | argumentsCount | The integer containing the arguments count of the method to get. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | An object representing the method that matches the specified requirements, if found; otherwise, null. |
GetProperty(Type, String)
Searches for the specified property, using the specified binding constraints.
Declaration
public static PropertyInfo GetProperty(Type type, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type used to get the property. |
System.String | propertyName | The string containing the name of the property to get. |
Returns
Type | Description |
---|---|
System.Reflection.PropertyInfo | An object representing the property that matches the specified requirements, if found; otherwise, null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | name is null. |
GetValue(Object, String)
Returns the property value of a specified object.
Declaration
public static object GetValue(object obj, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object whose field value will be returned. |
System.String | propertyName | The string containing the name of the property or field to get value. |
Returns
Type | Description |
---|---|
System.Object | The property value of the specified object. |
Invoke(MethodInfo, Object, Object[])
Invokes the method or constructor represented by the current instance, using the specified parameters.
Declaration
public static object Invoke(MethodInfo method, object obj, object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | method | The method information. |
System.Object | obj | The object on which to invoke the method or constructor. If a method is static, this argument is ignored. If a constructor is static, this argument must be null or an instance of the class that defines the constructor. |
System.Object[] | parameters | An argument list for the invoked method or constructor. This is an array of objects with the same number, order, and type as the parameters of the method or constructor to be invoked. |
Returns
Type | Description |
---|---|
System.Object | An object containing the return value of the invoked method, or null in the case of a constructor.CautionElements of the parameters array that represent parameters declared with the ref or out keyword may also be modified. |
SetValue(Object, String, Object)
Sets the property value of a specified object.
Declaration
public static bool SetValue(object obj, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object whose property value will be set. |
System.String | propertyName | The name of the property. |
System.Object | value | The new property value. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if value set properly, otherwise false. |