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
methodMethodBaseThe method to extract a signature for.
Exceptions
- ArgumentNullException
methodis null.
MethodDescriptor(Type, MethodBase)
Initializes a new instance of the MethodDescriptor class.
public MethodDescriptor(Type caller, MethodBase method)
Parameters
callerTypeThe class on which the
methodresides.methodMethodBaseThe method to extract a signature for.
Exceptions
- ArgumentNullException
methodis 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(params object[])
Associates the specified arguments to this instance.
public MethodDescriptor AppendRuntimeArguments(params object[] arguments)
Parameters
argumentsobject[]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
methodMethodBaseThe 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, params object[])
Merges the method parameter signature with the specified runtimeParameterValues.
public static IDictionary<string, object> MergeParameters(MethodDescriptor method, params object[] runtimeParameterValues)
Parameters
methodMethodDescriptorThe method holding the parameter signature to merge with the runtime parameter values.
runtimeParameterValuesobject[]The runtime parameter values.
Returns
- IDictionary<string, object>
An IDictionary<TKey, TValue> containing the merged result of the
methodparameter signature andruntimeParameterValues.
MergeParameters(IEnumerable<ParameterSignature>, params object[])
Merges the parameters signature with the specified runtimeParameterValues.
public static IDictionary<string, object> MergeParameters(IEnumerable<ParameterSignature> parameters, params object[] runtimeParameterValues)
Parameters
parametersIEnumerable<ParameterSignature>The parameter signature to merge with the runtime parameter values.
runtimeParameterValuesobject[]The runtime parameter values.
Returns
- IDictionary<string, object>
An IDictionary<TKey, TValue> containing the merged result of the
parameterssignature andruntimeParameterValues.
MergeParameters(params object[])
Merges the Parameters signature of this instance with the specified runtimeParameterValues.
public IDictionary<string, object> MergeParameters(params object[] runtimeParameterValues)
Parameters
runtimeParameterValuesobject[]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(bool)
Returns a string that represents the method signature.
public string ToString(bool fullName)
Parameters
fullNameboolSpecify
trueto use the fully qualified name of the Caller; otherwise,falsefor 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]]