Class MethodDescriptor
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Provides information about a method, such as its name, parameters and whether its a property or method.
public sealed class MethodDescriptor
- Inheritance
-
MethodDescriptor
Constructors
MethodDescriptor(MethodBase)
Initializes a new instance of the MethodDescriptor class.
public MethodDescriptor(MethodBase method)
Parameters
method
MethodBaseThe method to extract a signature for.
Exceptions
- ArgumentNullException
method
is null.
MethodDescriptor(Type, MethodBase)
Initializes a new instance of the MethodDescriptor class.
public MethodDescriptor(Type caller, MethodBase method)
Parameters
caller
TypeThe class on which the
method
resides.method
MethodBaseThe method to extract a signature for.
Exceptions
- ArgumentNullException
method
is null.
Properties
Caller
public Type Caller { get; }
Property Value
Method
Gets the MethodBase of this instance.
public MethodBase Method { get; }
Property Value
- MethodBase
The MethodBase of this instance.
MethodName
Gets the name of the method.
public string MethodName { get; }
Property Value
- String
The name of the method.
Parameters
Gets the parameters of the method.
public IEnumerable<ParameterSignature> Parameters { get; }
Property Value
- IEnumerable<ParameterSignature>
A sequence of type ParameterSignature containing information that matches the signature of the method.
RuntimeArguments
Gets the runtime arguments, if any, that was associated with this instance.
public IReadOnlyDictionary<string, object> RuntimeArguments { get; }
Property Value
- IReadOnlyDictionary<String, Object>
The runtime arguments, if any, that was associated with this instance.
Methods
AppendRuntimeArguments(Object[])
Associates the specified arguments
to this instance.
public MethodDescriptor AppendRuntimeArguments(params object[] arguments)
Parameters
arguments
Object[]The runtime arguments to associate with this instance.
Returns
- MethodDescriptor
A reference to this instance after the operation has completed.
Create(MethodBase)
Creates and returns a MethodDescriptor object and automatically determines the type of the signature (be that method or property).
public static MethodDescriptor Create(MethodBase method)
Parameters
method
MethodBaseThe method to extract a signature for.
Returns
- MethodDescriptor
A MethodDescriptor object.
Remarks
Although confusing a property is to be thought of as a method with either one or two methods (Get, Set) contained inside the property declaration.
MergeParameters(MethodDescriptor, Object[])
Merges the method
parameter signature with the specified runtimeParameterValues
.
public static IDictionary<string, object> MergeParameters(MethodDescriptor method, params object[] runtimeParameterValues)
Parameters
method
MethodDescriptorThe method holding the parameter signature to merge with the runtime parameter values.
runtimeParameterValues
Object[]The runtime parameter values.
Returns
- IDictionary<String, Object>
An IDictionary<TKey,TValue> containing the merged result of the
method
parameter signature andruntimeParameterValues
.
MergeParameters(IEnumerable<ParameterSignature>, Object[])
Merges the parameters
signature with the specified runtimeParameterValues
.
public static IDictionary<string, object> MergeParameters(IEnumerable<ParameterSignature> parameters, params object[] runtimeParameterValues)
Parameters
parameters
IEnumerable<ParameterSignature>The parameter signature to merge with the runtime parameter values.
runtimeParameterValues
Object[]The runtime parameter values.
Returns
- IDictionary<String, Object>
An IDictionary<TKey,TValue> containing the merged result of the
parameters
signature andruntimeParameterValues
.
MergeParameters(Object[])
Merges the Parameters signature of this instance with the specified runtimeParameterValues
.
public IDictionary<string, object> MergeParameters(params object[] runtimeParameterValues)
Parameters
runtimeParameterValues
Object[]The runtime parameter values.
Returns
- IDictionary<String, Object>
An IDictionary<TKey,TValue> containing the merged result of the Parameters signature of this instance and
runtimeParameterValues
.
ToString()
Returns a String that represents the method signature.
public override string ToString()
Returns
ToString(Boolean)
Returns a String that represents the method signature.
public string ToString(bool fullName)
Parameters
fullName
BooleanSpecify
true
to use the fully qualified name of the Caller; otherwise,false
for the simple name.
Returns
Remarks
The returned string has the following format:
Method without parameters: [Caller].MethodName
Method with at least one or more parameter: [Caller].[MethodName]([ParameterType] [ParameterName])
Property: [Caller].[MethodName]
Property with at least one indexer: [Caller].[MethodName][[ParameterType] [ParameterName]]