make stuff nonstatic
This commit is contained in:
1 parent
29eecc7887
commit
2cf6cd4a7d
3 files changed
+40
-15
No files matched your search
@@ -2,14 +2,25 @@
|
||||
|
||||
namespace SimpleHttpServer.Types;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public abstract class BaseEndpointCheckAttribute : Attribute {
|
||||
|
||||
public BaseEndpointCheckAttribute() { }
|
||||
|
||||
public abstract class InternalEndpointCheckAttribute : Attribute {
|
||||
/// <summary>
|
||||
/// Executed when the endpoint is invoked. The endpoint invocation is skipped if any of the checks fail.
|
||||
/// </summary>
|
||||
/// <returns>True to allow invocation, false to prevent.</returns>
|
||||
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<T> : InternalEndpointCheckAttribute {
|
||||
/// <summary>
|
||||
/// A reference to the instance of the class that this attribute is attached to.
|
||||
/// Will be null iff an class factory was passed in <see cref="HttpServer.RegisterEndpointsFromType{T}(Func{T}?)"/>.
|
||||
/// </summary>
|
||||
protected internal T? EndpointClassInstance { get; internal set; } = default;
|
||||
public BaseEndpointCheckAttribute() { }
|
||||
internal override void SetInstance(object? instance) {
|
||||
if (instance != null)
|
||||
EndpointClassInstance = (T?) instance;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user