Class ParameterSignature
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Represent the signature of a parameter to a method, property or similar.
public sealed class ParameterSignature
- Inheritance
-
ParameterSignature
Examples
The following example demonstrates how to use
using System;
using System.Linq;
using System.Reflection;
using Cuemon.Reflection;
namespace MyApp.Examples;
public class ParameterSignatureExample
{
public void Demonstrate()
{
MethodInfo method = typeof(string).GetMethod("IndexOf", new[] { typeof(string), typeof(StringComparison) });
if (method != null)
{
var signatures = ParameterSignature.Parse(method).ToList();
foreach (var signature in signatures)
{
Console.WriteLine($"Parameter: {signature.ParameterName}, Type: {signature.ParameterType.Name}");
}}}
}
Constructors
ParameterSignature(Type, string)
Initializes a new instance of the ParameterSignature class.
public ParameterSignature(Type parameterType, string parameterName)
Parameters
Exceptions
- ArgumentNullException
parameterTypeis null or
parameterNameis null.
Properties
ParameterName
Gets the name of the parameter.
public string ParameterName { get; }
Property Value
- string
The name of the parameter.
ParameterType
Gets the Type of the parameter.
public Type ParameterType { get; }
Property Value
Methods
Parse(IEnumerable<ParameterInfo>)
Converts the specified ParameterInfo sequence to its IEnumerable<T> equivalent.
public static IEnumerable<ParameterSignature> Parse(IEnumerable<ParameterInfo> parameters)
Parameters
parametersIEnumerable<ParameterInfo>A sequence of ParameterInfo.
Returns
- IEnumerable<ParameterSignature>
An IEnumerable<T> that is equivalent to the ParameterInfo sequence.
Exceptions
- ArgumentNullException
parametersis null.
Parse(MethodBase)
Extracts and converts the ParameterInfo sequence to its IEnumerable<T> equivalent from GetParameters().
public static IEnumerable<ParameterSignature> Parse(MethodBase method)
Parameters
methodMethodBaseThe MethodBase to extract parameter information from.
Returns
- IEnumerable<ParameterSignature>
An IEnumerable<T> that is equivalent to the ParameterInfo sequence in GetParameters().
Exceptions
- ArgumentNullException
methodis null.