Class MethodDescriptor
Provides information about a method, such as its name, parameters and whether its a property or method.
Inheritance
Namespace: Cuemon.Reflection
Assembly: Cuemon.Core.dll
Syntax
public sealed class MethodDescriptor
Constructors
| Improve this DocMethodDescriptor(MethodBase)
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(MethodBase method)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodBase | method | The method to extract a signature for. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
MethodDescriptor(Type, MethodBase)
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(Type caller, MethodBase method)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.Reflection.MethodBase | method | The method to extract a signature for. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
MethodDescriptor(Type, String)
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(Type caller, string methodName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
Remarks
This represents a method with no parameters.
MethodDescriptor(Type, String, ParameterSignature[])
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(Type caller, string methodName, params ParameterSignature[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
ParameterSignature[] | parameters | A sequence of ParameterSignature that represent the parameter signature of the method. |
Remarks
This represents a method with one or more parameters.
MethodDescriptor(Type, String, Boolean)
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(Type caller, string methodName, bool isProperty)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
System.Boolean | isProperty | A value indicating whether the method is a property. Default is |
Remarks
This represents a method with no parameters or a normal property.
MethodDescriptor(Type, String, Boolean, ParameterSignature[])
Initializes a new instance of the MethodDescriptor class.
Declaration
public MethodDescriptor(Type caller, string methodName, bool isProperty, params ParameterSignature[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
System.Boolean | isProperty | A value indicating whether the method is a property. Default is |
ParameterSignature[] | parameters | A sequence of ParameterSignature that represent the parameter signature of the method. |
Remarks
This represents a method with one or more parameters or a property indexer.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
ArgumentEmptyException |
|
Properties
| Improve this DocCaller
Gets the name of the class where the method is located.
Declaration
public Type Caller { get; }
Property Value
Type | Description |
---|---|
System.Type | The name of the class where the method is located. |
HasParameters
Gets a value indicating whether the method has parameters.
Declaration
public bool HasParameters { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsProperty
Gets a value indicating whether the method is a property.
Declaration
public bool IsProperty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
MethodName
Gets the name of the method.
Declaration
public string MethodName { get; }
Property Value
Type | Description |
---|---|
System.String | The name of the method. |
Parameters
Gets the parameter of the method.
Declaration
public IEnumerable<ParameterSignature> Parameters { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ParameterSignature> | A sequence of type ParameterSignature containing information that matches the signature of the method. |
Methods
| Improve this DocCreate(MethodBase)
Creates and returns a MethodDescriptor object and automatically determines the type of the signature (be that method or property).
Declaration
public static MethodDescriptor Create(MethodBase method)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodBase | method | The method to extract a signature for. |
Returns
Type | Description |
---|---|
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.
CreateMethod(Type, String)
Creates and returns a MethodDescriptor object.
Declaration
public static MethodDescriptor CreateMethod(Type caller, string methodName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
Returns
Type | Description |
---|---|
MethodDescriptor | A MethodDescriptor object. |
CreateMethod(Type, String, ParameterSignature[])
Creates and returns a MethodDescriptor object.
Declaration
public static MethodDescriptor CreateMethod(Type caller, string methodName, params ParameterSignature[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | methodName | The name of the method. |
ParameterSignature[] | parameters | A sequence of ParameterSignature that represent the parameter signature of the method. |
Returns
Type | Description |
---|---|
MethodDescriptor | A MethodDescriptor object. |
CreateProperty(Type, String)
Creates and returns a MethodDescriptor object.
Declaration
public static MethodDescriptor CreateProperty(Type caller, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | propertyName | The name of the property. |
Returns
Type | Description |
---|---|
MethodDescriptor | A MethodDescriptor object with IsProperty initialized to |
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.
CreateProperty(Type, String, ParameterSignature[])
Creates and returns a MethodDescriptor object.
Declaration
public static MethodDescriptor CreateProperty(Type caller, string propertyName, params ParameterSignature[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | caller | The class on which the |
System.String | propertyName | The name of the property. |
ParameterSignature[] | parameters | A sequence of ParameterSignature that represent the parameter signature of the method. |
Returns
Type | Description |
---|---|
MethodDescriptor | A MethodDescriptor object with IsProperty initialized to |
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
.
Declaration
public static IDictionary<string, object> MergeParameters(MethodDescriptor method, params object[] runtimeParameterValues)
Parameters
Type | Name | Description |
---|---|---|
MethodDescriptor | method | The method holding the parameter signature to merge with the runtime parameter values. |
System.Object[] | runtimeParameterValues | The runtime parameter values. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | An System.Collections.Generic.IDictionary<TKey, TValue> containing the merged result of the |
MergeParameters(IEnumerable<ParameterSignature>, Object[])
Merges the parameters
signature with the specified runtimeParameterValues
.
Declaration
public static IDictionary<string, object> MergeParameters(IEnumerable<ParameterSignature> parameters, params object[] runtimeParameterValues)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ParameterSignature> | parameters | The parameter signature to merge with the runtime parameter values. |
System.Object[] | runtimeParameterValues | The runtime parameter values. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | An System.Collections.Generic.IDictionary<TKey, TValue> containing the merged result of the |
MergeParameters(Object[])
Merges the Parameters signature of this instance with the specified runtimeParameterValues
.
Declaration
public IDictionary<string, object> MergeParameters(params object[] runtimeParameterValues)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | runtimeParameterValues | The runtime parameter values. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | An System.Collections.Generic.IDictionary<TKey, TValue> containing the merged result of the Parameters signature of this instance and |
ToString()
Returns a System.String that represents the method signature.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents the method signature. |
Overrides
ToString(Boolean)
Returns a System.String that represents the method signature.
Declaration
public string ToString(bool fullName)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | fullName | Specify |
Returns
Type | Description |
---|---|
System.String | A System.String that represents the method signature. |
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]]