Code/SboxSuperuser/Engine/CommandDiscovery/HandlerSignature8.cs

Part of a command discovery system. One of several generic IHandlerSignature implementations; Validate creates a typed Func delegate from a MethodDescription to confirm the method binds to an 8-parameter handler returning either CommandResult or Task<CommandResult>, without invoking it.

namespace SboxSuperuser.Engine.CommandDiscovery;

internal sealed class HandlerSignature8<T1, T2, T3, T4, T5, T6, T7, T8> : IHandlerSignature
{
	/// <summary>Checks closed delegate binding without executing the handler.</summary>
	public void Validate( Sandbox.MethodDescription method )
	{
		if ( method.ReturnType == typeof( CommandResult ) )
		{
			_ = method.CreateDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, CommandResult>>();
		}
		else
		{
			_ = method.CreateDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, Task<CommandResult>>>();
		}
	}
}