C# Class NuGetConsole.Host.MethodBinder

A simple method binder to call interface methods.
Mostra file Open project: monoman/NugetCracker

Public Methods

Method Description
ConvertToType ( object arg ) : Type

Convert an arg to a Type.

Invoke ( MethodInfo method, object target, object args ) : object

Invoke a method.

IsType ( object arg ) : bool

Determines if an arg represents a Type. If true, ConvertToType will be called to get the Type. Used for generic methods.

Protected Methods

Method Description
ChangeType ( ParameterInfo parameterInfo, object arg ) : object

Helper method to Convert an arg to a parameter type. This method in turn calls System.Convert.ChangeType().

CreateResultTuple ( IList allResults ) : object

Create a tuple to return method call results. The results include the method return value and omitted [out] parameter values.

IsUnwrapArgsNeeded ( ParameterInfo parameterInfos ) : bool

Check if unwrap args is needed. If false, UnwrapArgs/WrapResult become NOP. The default implementation returns true if there is any [out] params.

TryReturnArg ( ParameterInfo parameterInfo, object arg, object argValue ) : bool

Try to rematch an arg with a parameter when returning from a method call. This is used to return values in [ref] args. This method is expected to do the same processing as TryConvertArg and return the same value. If a [ref] parameter is present, return the argValue in the arg.

Private Methods

Method Description
TryConvertArg ( ParameterInfo parameterInfo, object arg, object &argValue ) : bool
TryGetOptionalArg ( ParameterInfo paramInfo, object &argValue ) : bool
TryInvoke ( Type type, string name, object target, object args, object &result ) : bool
UnwrapArgs ( MethodInfo m, object args ) : object[]
WrapResult ( MethodInfo m, object args, object result, object unwrappedArgs ) : object

Method Details

ChangeType() protected static method

Helper method to Convert an arg to a parameter type. This method in turn calls System.Convert.ChangeType().
protected static ChangeType ( ParameterInfo parameterInfo, object arg ) : object
parameterInfo System.Reflection.ParameterInfo The expected parameter info.
arg object The arg value.
return object

ConvertToType() public method

Convert an arg to a Type.
public ConvertToType ( object arg ) : Type
arg object An arg object.
return System.Type

CreateResultTuple() protected method

Create a tuple to return method call results. The results include the method return value and omitted [out] parameter values.
protected CreateResultTuple ( IList allResults ) : object
allResults IList The results list.
return object

Invoke() public method

Invoke a method.
public Invoke ( MethodInfo method, object target, object args ) : object
method System.Reflection.MethodInfo The method info.
target object The target object to invoke the method.
args object Arguments for the method call.
return object

IsType() public method

Determines if an arg represents a Type. If true, ConvertToType will be called to get the Type. Used for generic methods.
public IsType ( object arg ) : bool
arg object An arg object.
return bool

IsUnwrapArgsNeeded() protected method

Check if unwrap args is needed. If false, UnwrapArgs/WrapResult become NOP. The default implementation returns true if there is any [out] params.
protected IsUnwrapArgsNeeded ( ParameterInfo parameterInfos ) : bool
parameterInfos System.Reflection.ParameterInfo All the parameterinfo.
return bool

TryReturnArg() protected abstract method

Try to rematch an arg with a parameter when returning from a method call. This is used to return values in [ref] args. This method is expected to do the same processing as TryConvertArg and return the same value. If a [ref] parameter is present, return the argValue in the arg.
protected abstract TryReturnArg ( ParameterInfo parameterInfo, object arg, object argValue ) : bool
parameterInfo System.Reflection.ParameterInfo The current expected parameter info.
arg object A passed in arg.
argValue object The arg value after the method call.
return bool