Class Invoker
Static methods to dynamically invoke methods and access fields of an object.
Assembly: Microsoft.ML.Probabilistic.Compiler.dll
Syntax
public static class Invoker
Methods
Clone(Object)
Clone an object by reflection on its fields.
Declaration
public static object Clone(object o)
Parameters
| Type |
Name |
Description |
| Object |
o |
|
Returns
Clone(Object, Boolean)
Declaration
public static object Clone(object o, bool cloneFields)
Parameters
Returns
GenericParameterCount(MethodBase)
Declaration
public static int GenericParameterCount(MethodBase method)
Parameters
Returns
GenericParameterCount(Type)
Declaration
public static int GenericParameterCount(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
|
Returns
GetBestMethod(MethodBase[], Type, Type[], ConversionOptions, out Binding, out Exception)
Find the method which best matches the given arguments.
Declaration
public static MethodBase GetBestMethod(MethodBase[] methods, Type targetType, Type[] argTypes, ConversionOptions conversionOptions, out Binding binding, out Exception exception)
Parameters
| Type |
Name |
Description |
| MethodBase[] |
methods |
Methods to search through
|
| Type |
targetType |
The type of this, for instance methods. If looking for a static method, use null.
|
| Type[] |
argTypes |
Types. argTypes.Length == number of method parameters. argTypes[i] may be null to allow any type, or typeof(Nullable) to mean "any nullable type".
|
| ConversionOptions |
conversionOptions |
Specifies which conversions are allowed
|
| Binding |
binding |
Modified to contain the generic type arguments and argument conversions needed for calling the method
|
| Exception |
exception |
Exception created on failure
|
Returns
| Type |
Description |
| MethodBase |
A non-null MethodBase.
|
Exceptions
GetBestMethod(MethodBase[], Type, Type[], out Exception)
Find the method which best matches the given arguments.
Declaration
public static MethodBase GetBestMethod(MethodBase[] methods, Type targetType, Type[] argTypes, out Exception exception)
Parameters
| Type |
Name |
Description |
| MethodBase[] |
methods |
|
| Type |
targetType |
The type of this, for instance methods. If looking for a static method, use null.
|
| Type[] |
argTypes |
Types. argTypes.Length == number of method parameters. argTypes[i] may be null to allow any type, or typeof(Nullable) to mean "any nullable type".
|
| Exception |
exception |
Exception created on failure
|
Returns
| Type |
Description |
| MethodBase |
A non-null MethodBase.
|
Exceptions
GetBestMethod(Type, String, BindingFlags, Type, Type[], out Exception)
Find the method which best matches the given arguments.
Declaration
public static MethodBase GetBestMethod(Type type, string memberName, BindingFlags flags, Type targetType, Type[] argTypes, out Exception exception)
Parameters
| Type |
Name |
Description |
| Type |
type |
|
| String |
memberName |
|
| BindingFlags |
flags |
|
| Type |
targetType |
The type of this, for instance methods. If looking for a static method, use null.
|
| Type[] |
argTypes |
Types. argTypes.Length == number of method parameters. argTypes[i] may be null to allow any type, or typeof(Nullable) to mean "any nullable type".
|
| Exception |
exception |
Exception created on failure
|
Returns
Exceptions
GetLoadedType(String)
Declaration
public static Type GetLoadedType(string typeName)
Parameters
| Type |
Name |
Description |
| String |
typeName |
The name of a type in the System library or any loaded assembly.
|
Returns
| Type |
Description |
| Type |
The Type object.
|
GetParameterTypes(MethodBase)
Declaration
public static Type[] GetParameterTypes(MethodBase method)
Parameters
Returns
GetTypeArray(Object[])
Gets the types of the objects in the specified array.
Declaration
public static Type[] GetTypeArray(object[] args)
Parameters
| Type |
Name |
Description |
| Object[] |
args |
An array of objects whose types to determine. args[i] can be null, whose type is assumed to be typeof(Nullable).
|
Returns
| Type |
Description |
| Type[] |
An array of Type objects representing the types of the corresponding elements in args.
|
GetValue(Object, Object[])
Get an element from an array or collection, or invoke a delegate.
Declaration
public static object GetValue(object target, params object[] args)
Parameters
| Type |
Name |
Description |
| Object |
target |
An array, collection, delegate, or method group.
|
| Object[] |
args |
Indices for the collection or arguments for the delegate. May be null.
|
Returns
| Type |
Description |
| Object |
The collection element or return value of the delegate. If args == null, the target itself.
|
HasAttribute(MemberInfo, Type)
Declaration
public static bool HasAttribute(MemberInfo member, Type attributeType)
Parameters
Returns
Invoke(MethodBase, Object, Object[])
Invoke a generic method by inferring type parameters from the method arguments.
Declaration
public static object Invoke(MethodBase method, object target, params object[] args)
Parameters
Returns
Invoke(MethodBase[], Object, Object[])
Invoke the method which best matches the argument types.
Declaration
public static object Invoke(MethodBase[] methods, object target, params object[] args)
Parameters
| Type |
Name |
Description |
| MethodBase[] |
methods |
A non-empty list of methods, exactly one of which will be invoked. Can include both static and instance methods.
|
| Object |
target |
The instance for an instance method, or if non-null, the first argument of a static method.
|
| Object[] |
args |
The remaining arguments of the method.
|
Returns
| Type |
Description |
| Object |
The return value of the method.
|
InvokeInstance(String, Object, Object[])
Invoke the instance member which best matches the argument types.
Declaration
public static object InvokeInstance(string methodName, object target, params object[] args)
Parameters
Returns
InvokeMember(Type, String, BindingFlags, Object, Object[])
Invoke the member which best matches the argument types.
Declaration
public static object InvokeMember(Type type, string memberName, BindingFlags flags, object target, params object[] args)
Parameters
| Type |
Name |
Description |
| Type |
type |
The type defining the member.
|
| String |
memberName |
The name of a field, property, event, instance method, or static method.
|
| BindingFlags |
flags |
|
| Object |
target |
The object whose member to invoke. Ignored for a static field or property.
If target is non-null, then it is provided as the first argument to a static method.
|
| Object[] |
args |
Can be empty or null. Empty means a function call with no arguments.
null means get the member itself.
|
Returns
| Type |
Description |
| Object |
The result of the invocation. For SetField/SetProperty the result is null.
|
Exceptions
InvokeStatic(Type, String, Object[])
Invoke the static member which best matches the argument types.
Declaration
public static object InvokeStatic(Type type, string methodName, params object[] args)
Parameters
Returns
op_Addition(Int32, Int32)
Declaration
public static int op_Addition(int a, int b)
Parameters
Returns
op_BooleanAnd(Boolean, Boolean)
Declaration
public static bool op_BooleanAnd(bool a, bool b)
Parameters
Returns
op_BooleanNot(Boolean)
Declaration
public static bool op_BooleanNot(bool b)
Parameters
Returns
op_BooleanOr(Boolean, Boolean)
Declaration
public static bool op_BooleanOr(bool a, bool b)
Parameters
Returns
op_Equality(Object, Object)
Declaration
public static bool op_Equality(object a, object b)
Parameters
Returns
op_GreaterThan(Int32, Int32)
Declaration
public static bool op_GreaterThan(int a, int b)
Parameters
Returns
op_GreaterThanOrEqual(Int32, Int32)
Declaration
public static bool op_GreaterThanOrEqual(int a, int b)
Parameters
Returns
op_Inequality(Object, Object)
Declaration
public static bool op_Inequality(object a, object b)
Parameters
Returns
op_LessThan(Int32, Int32)
Declaration
public static bool op_LessThan(int a, int b)
Parameters
Returns
op_LessThanOrEqual(Int32, Int32)
Declaration
public static bool op_LessThanOrEqual(int a, int b)
Parameters
Returns
op_Subtraction(Int32, Int32)
Declaration
public static int op_Subtraction(int a, int b)
Parameters
Returns
op_UnaryNegation(Int32)
Declaration
public static int op_UnaryNegation(int a)
Parameters
| Type |
Name |
Description |
| Int32 |
a |
|
Returns
PrintTypes(Type[])
Declaration
public static string PrintTypes(Type[] types)
Parameters
| Type |
Name |
Description |
| Type[] |
types |
|
Returns
SetValue(Object, Object[])
Set an element in an array or collection.
Declaration
public static void SetValue(object target, params object[] args)
Parameters
| Type |
Name |
Description |
| Object |
target |
An array or collection.
|
| Object[] |
args |
Indices followed by the value to set. Length > 0.
|