Class ActivatorExt
APIs to call reflection-based invoke operations with automatic unwrap of TargetInvocationException on error.
public static class ActivatorExt
- Inheritance
-
ActivatorExt
- Inherited Members
Methods
CreateInstance(Type)
Creates instance of type type. Ensures that instance is not null.
public static object CreateInstance(Type type)
Parameters
typeType
Returns
CreateInstance(Type, bool)
Creates instance of type type.
public static object CreateInstance(Type type, bool nonPublic)
Parameters
Returns
CreateInstance(Type, params object?[]?)
Creates instance of type type.
public static object CreateInstance(Type type, params object?[]? args)
Parameters
Returns
CreateInstance<T>()
Creates instance of T type.
public static T CreateInstance<T>()
Returns
- T
Type Parameters
T
CreateInstance<T>(Type)
Creates instance of type and asserts it inherits/implements T.
public static T CreateInstance<T>(Type type) where T : class
Parameters
typeType
Returns
- T
Type Parameters
T
CreateInstance<T>(Type, bool)
Creates instance of type and asserts it inherits/implements T.
public static T CreateInstance<T>(Type type, bool nonPublic) where T : class
Parameters
Returns
- T
Type Parameters
T
CreateInstance<T>(Type, params object?[]?)
Creates instance of type and asserts it inherits/implements T.
public static T CreateInstance<T>(Type type, params object?[]? args) where T : class
Parameters
Returns
- T
Type Parameters
T
DynamicInvokeExt(Delegate, params object?[]?)
Invokes delegate.
public static object? DynamicInvokeExt(this Delegate method, params object?[]? args)
Parameters
Returns
DynamicInvokeExt<T>(Delegate, params object?[]?)
Invokes delegate and asserts it return value of T type.
public static T DynamicInvokeExt<T>(this Delegate method, params object?[]? args)
Parameters
Returns
- T
Type Parameters
T
InvokeExt(ConstructorInfo, object?[]?)
Creates object instance by invoking contructor.
public static object InvokeExt(this ConstructorInfo ctor, object?[]? parameters)
Parameters
ctorConstructorInfoparametersobject[]
Returns
InvokeExt(MethodBase, object?, object?[]?)
Invokes method.
public static object? InvokeExt(this MethodBase method, object? obj, object?[]? parameters)
Parameters
methodMethodBaseobjobjectparametersobject[]
Returns
InvokeExt<T>(ConstructorInfo, object?[]?)
Creates object instance by invoking contructor and asserts created instance inherits/implements T.
public static T InvokeExt<T>(this ConstructorInfo ctor, object?[]? parameters) where T : class
Parameters
ctorConstructorInfoparametersobject[]
Returns
- T
Type Parameters
T
InvokeExt<T>(MethodBase, object?, object?[]?)
Invokes method and asserts it return value of T type.
public static T InvokeExt<T>(this MethodBase method, object? obj, object?[]? parameters)
Parameters
methodMethodBaseobjobjectparametersobject[]
Returns
- T
Type Parameters
T