CSharpHttpServer/SimpleHttpServer/Types/EndpointInvocationInfo.cs

20 lines
900 B
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 BaseEndpointCheckAttribute[] requiredChecks;
public EndpointInvocationInfo(MethodInfo methodInfo, List<QueryParameterInfo> queryParameters, BaseEndpointCheckAttribute[] requiredChecks) {
this.methodInfo = methodInfo ?? throw new ArgumentNullException(nameof(methodInfo));
this.queryParameters = queryParameters ?? throw new ArgumentNullException(nameof(queryParameters));
this.requiredChecks = requiredChecks;
}
public readonly bool CheckAll(HttpListenerRequest req) => requiredChecks.All(x => x.Check(req));
}