90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
|
|
using System;
|
|
|
|
namespace ln.http.api.attributes
|
|
{
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
|
public abstract class EndpointAttribute : Attribute
|
|
{
|
|
public string Route { get; set; }
|
|
public HttpMethod Method { get; set; }
|
|
|
|
public EndpointAttribute(HttpMethod method, string route)
|
|
{
|
|
Method = method;
|
|
Route = route;
|
|
}
|
|
|
|
}
|
|
|
|
public class HEADAttribute : EndpointAttribute
|
|
{
|
|
public HEADAttribute(string route) : base(HttpMethod.HEAD, route){}
|
|
}
|
|
public class GETAttribute : EndpointAttribute
|
|
{
|
|
public GETAttribute(string route) : base(HttpMethod.GET, route){}
|
|
}
|
|
public class POSTAttribute : EndpointAttribute
|
|
{
|
|
public POSTAttribute(string route) : base(HttpMethod.POST, route){}
|
|
}
|
|
public class PUTAttribute : EndpointAttribute
|
|
{
|
|
public PUTAttribute(string route) : base(HttpMethod.PUT, route){}
|
|
}
|
|
public class PATCHAttribute : EndpointAttribute
|
|
{
|
|
public PATCHAttribute(string route) : base(HttpMethod.PATCH, route){}
|
|
}
|
|
public class DELETEAttribute : EndpointAttribute
|
|
{
|
|
public DELETEAttribute(string route) : base(HttpMethod.DELETE, route){}
|
|
}
|
|
public class CONNECTAttribute : EndpointAttribute
|
|
{
|
|
public CONNECTAttribute(string route) : base(HttpMethod.CONNECT, route){}
|
|
}
|
|
public class OPTIONSAttribute : EndpointAttribute
|
|
{
|
|
public OPTIONSAttribute(string route) : base(HttpMethod.OPTIONS, route){}
|
|
}
|
|
public class TRACEAttribute : EndpointAttribute
|
|
{
|
|
public TRACEAttribute(string route) : base(HttpMethod.TRACE, route){}
|
|
}
|
|
|
|
|
|
public abstract class ArgumentSourceAttribute : Attribute
|
|
{
|
|
public static readonly ArgumentSourceAttribute Default = new DefaultArgumentSourceAttribute();
|
|
public string SourceName { get; set; }
|
|
public ArgumentSource Source { get; }
|
|
|
|
public ArgumentSourceAttribute(ArgumentSource source)
|
|
{
|
|
Source = source;
|
|
}
|
|
|
|
class DefaultArgumentSourceAttribute : ArgumentSourceAttribute
|
|
{
|
|
public DefaultArgumentSourceAttribute() :base(ArgumentSource.AUTO) {}
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Parameter)]
|
|
public class FromParameterAttribute : ArgumentSourceAttribute
|
|
{
|
|
public FromParameterAttribute() :base(ArgumentSource.PARAMETER) {}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Parameter)]
|
|
public class FromContentAttribute : ArgumentSourceAttribute
|
|
{
|
|
public FromContentAttribute() :base(ArgumentSource.CONTENT) {}
|
|
}
|
|
|
|
|
|
|
|
} |