Class MethodSignature
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Represent the signature of a method in a lightweight format.
public class MethodSignature
- Inheritance
-
MethodSignature
Examples
The following example shows how to capture lightweight method metadata for logging or retry evidence.
using System;
using Cuemon.Reflection;
namespace MyApp.Examples;
public static class MethodSignatureExample
{
public static void Demonstrate()
{
var signature = new MethodSignature(
typeof(PaymentGateway).FullName ?? nameof(PaymentGateway),
nameof(PaymentGateway.Authorize),
new[] { typeof(string).Name, typeof(decimal).Name },
new object[] { "INV-42", 19.95m });
Console.WriteLine(signature.ToString());
Console.WriteLine(string.Join(", ", signature.Parameters ?? Array.Empty<string>()));
Console.WriteLine(signature.Arguments?.Length ?? 0);
}
}
public sealed class PaymentGateway
{
public void Authorize(string orderId, decimal amount)
{
}
}
Constructors
MethodSignature(string, string, string[], object[])
Initializes a new instance of the MethodSignature class.
public MethodSignature(string caller, string methodName, string[] parameters, object[] arguments)
Parameters
callerstringThe class on which the method portrayed by
methodNameresides.methodNamestringThe name of the method to portray.
parametersstring[]The optional parameters of the method portrayed by
methodName.argumentsobject[]The optional runtime arguments passed to the method portrayed by
methodName.
Properties
Arguments
Gets the runtime arguments (if any) that was passed to the portrayed method.
public object[] Arguments { get; }
Property Value
- object[]
An array of objects that was passed to the portrayed method.
Caller
Gets the caller of the class where the method portrayed by MethodName is located.
public string Caller { get; }
Property Value
- string
The caller of the class where the method portrayed by MethodName is located.
MethodName
Gets the name of the portrayed method.
public string MethodName { get; }
Property Value
- string
The name of the portrayed method.
Parameters
Gets the parameters (if any) of the portrayed method.
public string[] Parameters { get; }
Property Value
- string[]
An array of string values that matches the signature of the portrayed method.
Methods
ToString()
Returns a string that represents this instance.
public override string ToString()