ReflectionUtils Class

Collection of Reflection and type conversion related utility functions

System.Object
   Westwind.Utilities.ReflectionUtils

Class Members

MemberDescription
CallMethod Calls a method on an object dynamically. This version doesn't require specific parameter signatures to be passed. Instead parameter types are inferred based on types passed. Note that if you pass a…
public static object CallMethod(object instance, string method, Type[] parameterTypes, object[] parms)
CallMethodCom Wrapper method to call a 'dynamic' (non-typelib) method on a COM object
public static object CallMethodCom(object instance, string method, object[] parms)
CallMethodEx Calls a method on an object with extended . syntax (object: this Method: Entity.CalculateOrderTotal)
public static object CallMethodEx(object parent, string method, object[] parms)
CallMethodExCom Calls a method on a COM object with '.' syntax (Customer instance and Address.DoSomeThing method)
public static object CallMethodExCom(object parent, string method, object[] parms)
CallStaticMethod Invokes a static method
public static object CallStaticMethod(string typeName, string method, object[] parms)
CreateComInstance Creates a COM instance from a ProgID. Loads either Exe or DLL servers.
public static object CreateComInstance(string progId)
CreateInstanceFromString Creates an instance of a type based on a string. Assumes that the type's
public static object CreateInstanceFromString(string typeName, object[] args)
CreateInstanceFromType Creates an instance from a type by calling the parameterless constructor. Note this will not work with COM objects - continue to use the Activator.CreateInstance for COM objects. Class wwUtils
public static object CreateInstanceFromType(Type typeToCreate, object[] args)
GetEnumList Returns a List of KeyValuePair object
public static List> GetEnumList(Type enumType, bool valueAsFieldValueNumber)
GetField Retrieve a field dynamically from an object. This is a simple implementation that's straight Reflection and doesn't support indexers.
public static object GetField(object Object, string Property)
GetProperty Retrieve a property value from an object dynamically. This is a simple version that uses Reflection calls directly. It doesn't support indexers.
public static object GetProperty(object instance, string property)
GetPropertyCom Retrieve a dynamic 'non-typelib' property
public static object GetPropertyCom(object instance, string property)
GetPropertyEx Returns a property or field value using a base object and sub members including . syntax. For example, you can access: oCustomer.oData.Company with (this,"oCustomer.oData.Company") This…
public static object GetPropertyEx(object Parent, string Property)
GetPropertyExCom Returns a property or field value using a base object and sub members including . syntax. For example, you can access: oCustomer.oData.Company with (this,"oCustomer.oData.Company")
public static object GetPropertyExCom(object parent, string property)
GetPropertyInfoEx Returns a PropertyInfo object for a given dynamically accessed property Property selection can be specified using . syntax ("Address.Street" or "DataTable[0].Rows[1]") hence the…
public static PropertyInfo GetPropertyInfoEx(object Parent, string Property)
GetPropertyInfoInternal Returns a PropertyInfo structure from an extended Property reference
public static PropertyInfo GetPropertyInfoInternal(object Parent, string Property)
GetStaticProperty Returns a static property from a given type
public static object GetStaticProperty(string typeName, string property)
GetTypeFromName Overload for backwards compatibility which only tries to load assemblies that are already loaded in memory.
public static Type GetTypeFromName(string typeName, string assemblyName)
InvokeEvent Allows invoking an event from an external classes where direct access is not allowed (due to 'Can only assign to left hand side of operation')
public static void InvokeEvent(object instance, string eventName, object[] parameters)
IsAnonoymousType Determines whether a given type passed is anonymous
public static bool IsAnonoymousType(object objectOrType)
LoadAssembly Try to load an assembly into the application's app domain. Loads by name first then checks for filename
public static Assembly LoadAssembly(string assemblyName)
SetField Sets the field on an object. This is a simple method that uses straight Reflection and doesn't support indexers.
public static void SetField(object obj, string property, object value)
SetProperty Sets the property on an object. This is a simple method that uses straight Reflection and doesn't support indexers.
public static void SetProperty(object obj, string property, object value)
SetPropertyCom Sets the property on an object.
public static void SetPropertyCom(object inst, string Property, object Value)
SetPropertyEx Sets a value on an object. Supports . syntax for named properties (ie. Customer.Entity.Company) as well as indexers.
public static object SetPropertyEx(object parent, string property, object value)
SetPropertyExCom Sets the value of a field or property via Reflection. This method alws for using '.' syntax to specify objects multiple levels…
public static object SetPropertyExCom(object parent, string property, object value)
ShallowClone Clones an object using a shallow cloning using private MemberwiseClone operation.
public static object ShallowClone(object source)
StringToTypedValue Turns a string into a typed value generically. Explicitly assigns common types and falls back on using type converters for unhandled types. Common uses: UI → to data conversions Parsers Class…
public static object StringToTypedValue(string sourceString, Type targetType, CultureInfo culture)
TypedValueToString Converts a type to string if possible. This method supports an optional culture generically on any value. It calls the ToString() method on common types and uses a type converter on all other…
public static string TypedValueToString(object rawValue, CultureInfo culture, string unsupportedReturn)
Namespace: Westwind.Utilities

Assembly: Westwind.Utilities.dll