using System.Net; namespace SimpleHttpServer.Types; public abstract class InternalEndpointCheckAttribute : Attribute { /// /// Executed when the endpoint is invoked. The endpoint invocation is skipped if any of the checks fail. /// /// True to allow invocation, false to prevent. public abstract bool Check(HttpListenerRequest req); internal abstract void SetInstance(object? instance); } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)] public abstract class BaseEndpointCheckAttribute : InternalEndpointCheckAttribute { /// /// A reference to the instance of the class that this attribute is attached to. /// Will be null iff an class factory was passed in . /// protected internal T? EndpointClassInstance { get; internal set; } = default; public BaseEndpointCheckAttribute() { } internal override void SetInstance(object? instance) { if (instance != null) EndpointClassInstance = (T?) instance; } }