25 lines
1.2 KiB
C#
25 lines
1.2 KiB
C#
using System.Net;
|
|
using System.Reflection;
|
|
|
|
namespace SimpleHttpServer.Types;
|
|
internal readonly struct EndpointInvocationInfo {
|
|
internal record struct QueryParameterInfo(string Name, Type Type, bool IsOptional);
|
|
|
|
internal readonly MethodInfo methodInfo;
|
|
internal readonly List<QueryParameterInfo> queryParameters;
|
|
internal readonly InternalEndpointCheckAttribute[] requiredChecks;
|
|
/// <summary>
|
|
/// a reference to the object in which this method is defined (or null if the class is static)
|
|
/// </summary>
|
|
internal readonly object? typeInstanceReference;
|
|
|
|
public EndpointInvocationInfo(MethodInfo methodInfo, List<QueryParameterInfo> queryParameters, InternalEndpointCheckAttribute[] requiredChecks, object? typeInstanceReference) {
|
|
this.methodInfo = methodInfo ?? throw new ArgumentNullException(nameof(methodInfo));
|
|
this.queryParameters = queryParameters ?? throw new ArgumentNullException(nameof(queryParameters));
|
|
this.requiredChecks = requiredChecks;
|
|
this.typeInstanceReference = typeInstanceReference;
|
|
}
|
|
|
|
public readonly bool CheckAll(HttpListenerRequest req) => requiredChecks.All(x => x.Check(req));
|
|
}
|