Class PrivateReflectionUsingDynamicExtensions
Namespace: Ludiq.ReflectionMagic
Syntax
public static class PrivateReflectionUsingDynamicExtensions
Methods
AsDynamic(Object)
Wraps the specified object in a dynamic object that allows access to private members.
Declaration
public static dynamic AsDynamic(this object o)
Parameters
Type | Name | Description |
---|---|---|
Object | o | The object to wrap |
Returns
Type | Description |
---|---|
Object | The wrapped object. |
Remarks
Does not wrap null
, String, primitive types, and already wrapped objects.
See Also
AsDynamicType(Type)
Wraps the specified type in a dynamic object which allows easy instantion through the New(Object[]) method.
Declaration
public static dynamic AsDynamicType(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to wrap. |
Returns
Type | Description |
---|---|
Object | The wrapped type. |
See Also
CreateDynamicInstance(Assembly, String, Object[])
Tries to instantiate the type with the specified type name from the specified assembly instance using the specified constructor arguments.
Declaration
public static dynamic CreateDynamicInstance(this Assembly assembly, string typeName, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | The assembly instance to search. |
String | typeName | The full type name. |
Object[] | args | The arguments to pass to the constructor. |
Returns
Type | Description |
---|---|
Object |
Exceptions
Type | Condition |
---|---|
MissingMethodException | Thrown when no suitable constructor can be found. |
GetDynamicType(Assembly, String)
Gets the type with the specified name from the specified assembly instance, and returns it as a dynamic object. See also AsDynamicType(Type).
Declaration
public static dynamic GetDynamicType(this Assembly assembly, string typeName)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | The assembly instance to search for the type. |
String | typeName | The type name. |
Returns
Type | Description |
---|---|
Object | The wrapped type. |