Invoker
Links
Summary
This library aims to make execution of functions on objects highly performant and easy as possible. In certain scenarios this is highly beneficial, for example, in a case where dependency injection is used to create a generic service at runtime and pass in required parameter information, execution can be slow. See an example from an inputs library use case:
var invoker = InvokerFactory.CreateInvoker(definitionType, method);
definitionBuilder.WithAction(new InputAction(inputActionName,
inputActionAttribute?.TriggerPhases.ToHashSet() ?? [InputPhase.Start],
inputEventContext => invoker.FastInvoke(inputEventContext.Services.GetRequiredService(definitionType), [inputEventContext]),
inputActionAttribute?.Description, inputActionAttribute?.InternalActionGroup));
The invoker is able to achieve performance near to that of executing a method directly on a known type, due to the usage of compiled expressions.
