Class ActivatorExt
APIs to call reflection-based invoke operations with automatic unwrap of TargetInvocationException on error.
public static class ActivatorExt
- Inheritance
-
objectActivatorExt
Methods
CreateInstance(Type)
Creates instance of type type. Ensures that instance is not null.
public static object CreateInstance(Type type)
Parameters
typeType
Returns
- object
CreateInstance(Type, bool)
Creates instance of type type.
public static object CreateInstance(Type type, bool nonPublic)
Parameters
Returns
- object
CreateInstance(Type, params object?[]?)
Creates instance of type type.
public static object CreateInstance(Type type, params object?[]? args)
Parameters
typeTypeargsobject[]
Returns
- object
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
typeTypeargsobject[]
Returns
- T
Type Parameters
T
DynamicInvokeExt(Delegate, params object?[]?)
Invokes delegate.
public static object? DynamicInvokeExt(this Delegate method, params object?[]? args)
Parameters
methodDelegateargsobject[]
Returns
- object
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
methodDelegateargsobject[]
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
- object
InvokeExt(MethodBase, object?, object?[]?)
Invokes method.
public static object? InvokeExt(this MethodBase method, object? obj, object?[]? parameters)
Parameters
methodMethodBaseobjobjectparametersobject[]
Returns
- object
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