Skip to content

MethodInvocation

NexusLabs.Needlr

NexusLabs.Needlr

MethodInvocation Class

Default implementation of IMethodInvocation used by generated interceptor proxy classes.

public sealed class MethodInvocation : NexusLabs.Needlr.IMethodInvocation

Inheritance System.Object 🡒 MethodInvocation

Implements IMethodInvocation

Constructors

MethodInvocation(object, MethodInfo, object[], Func<ValueTask<object>>) Constructor

Initializes a new instance of the MethodInvocation class for non-generic methods.

public MethodInvocation(object target, System.Reflection.MethodInfo method, object?[] arguments, System.Func<System.Threading.Tasks.ValueTask<object?>> proceed);

Parameters

target System.Object

The target service instance.

method System.Reflection.MethodInfo

The method being invoked.

arguments System.Object[]

The arguments passed to the method.

proceed System.Func<System.Threading.Tasks.ValueTask<System.Object>>

A function that invokes the next interceptor or the actual method.

MethodInvocation(object, MethodInfo, object[], Type[], Func<ValueTask<object>>) Constructor

Initializes a new instance of the MethodInvocation class.

public MethodInvocation(object target, System.Reflection.MethodInfo method, object?[] arguments, System.Type[] genericArguments, System.Func<System.Threading.Tasks.ValueTask<object?>> proceed);

Parameters

target System.Object

The target service instance.

method System.Reflection.MethodInfo

The method being invoked.

arguments System.Object[]

The arguments passed to the method.

genericArguments System.Type[]

The generic type arguments (empty for non-generic methods).

proceed System.Func<System.Threading.Tasks.ValueTask<System.Object>>

A function that invokes the next interceptor or the actual method.

Properties

MethodInvocation.Arguments Property

Gets the arguments passed to the method. The array can be modified to change argument values before calling ProceedAsync().

public object?[] Arguments { get; }

Implements Arguments

Property Value

System.Object[]

MethodInvocation.GenericArguments Property

Gets the generic type arguments if the method is a generic method. Returns an empty array for non-generic methods.

public System.Type[] GenericArguments { get; }

Implements GenericArguments

Property Value

System.Type[]

MethodInvocation.Method Property

Gets metadata about the method being invoked.

public System.Reflection.MethodInfo Method { get; }

Implements Method

Property Value

System.Reflection.MethodInfo

MethodInvocation.Target Property

Gets the target service instance on which the method is being invoked.

public object Target { get; }

Implements Target

Property Value

System.Object

Methods

MethodInvocation.ProceedAsync() Method

Proceeds to the next interceptor in the chain, or to the actual method implementation if this is the last interceptor.

public System.Threading.Tasks.ValueTask<object?> ProceedAsync();

Implements ProceedAsync()

Returns

System.Threading.Tasks.ValueTask<System.Object>
The result of the method (or the result from the next interceptor). Returns null for void methods.