From 2e4570a560bd24de2271ede0f3ee79cf66db5fc3 Mon Sep 17 00:00:00 2001 From: 00asdf Date: Sat, 27 Jul 2024 00:16:38 +0200 Subject: [PATCH] initialize endpoint attributes (untested, yeet) --- SimpleHttpServer/HttpServer.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SimpleHttpServer/HttpServer.cs b/SimpleHttpServer/HttpServer.cs index 3bffdc5..b738e30 100644 --- a/SimpleHttpServer/HttpServer.cs +++ b/SimpleHttpServer/HttpServer.cs @@ -132,11 +132,12 @@ public sealed class HttpServer { } // stores the check attributes that are defined on the method and on the containing class - var requiredChecks = mi.GetCustomAttributes(true).Concat(mi.DeclaringType?.GetCustomAttributes(true) ?? Enumerable.Empty()) - .Where(a => a.GetType().IsAssignableTo(typeof(InternalEndpointCheckAttribute))).Cast().ToArray(); + InternalEndpointCheckAttribute[] requiredChecks = mi.GetCustomAttributes(true) + .Concat(mi.DeclaringType?.GetCustomAttributes(true) ?? Enumerable.Empty()) + .Where(a => a.GetType().IsAssignableTo(typeof(InternalEndpointCheckAttribute))) + .Cast().ToArray(); - foreach (var requiredCheck in requiredChecks) - requiredCheck.SetInstance(classInstance); + InternalEndpointCheckAttribute.Initialize(classInstance, requiredChecks); foreach (var location in attrib.Locations) { var normLocation = NormalizeUrlPath(location);