using System.Net; namespace MaksIT.Results; public partial class Result { /// /// Returns a result indicating the server encountered an unexpected condition that prevented it from fulfilling the request. /// Corresponds to HTTP status code 500 Internal Server Error. /// public static Result InternalServerError(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.InternalServerError); } /// /// Returns a result indicating the server does not support the functionality required to fulfill the request. /// Corresponds to HTTP status code 501 Not Implemented. /// public static Result NotImplemented(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.NotImplemented); } /// /// Returns a result indicating the server, while acting as a gateway or proxy, received an invalid response from the upstream server. /// Corresponds to HTTP status code 502 Bad Gateway. /// public static Result BadGateway(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.BadGateway); } /// /// Returns a result indicating the server is currently unable to handle the request due to temporary overload or maintenance of the server. /// Corresponds to HTTP status code 503 Service Unavailable. /// public static Result ServiceUnavailable(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.ServiceUnavailable); } /// /// Returns a result indicating the server, while acting as a gateway or proxy, did not receive a timely response from the upstream server. /// Corresponds to HTTP status code 504 Gateway Timeout. /// public static Result GatewayTimeout(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.GatewayTimeout); } /// /// Returns a result indicating the server does not support the HTTP protocol version used in the request. /// Corresponds to HTTP status code 505 HTTP Version Not Supported. /// public static Result HttpVersionNotSupported(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.HttpVersionNotSupported); } /// /// Returns a result indicating the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process. /// Corresponds to HTTP status code 506 Variant Also Negotiates. /// public static Result VariantAlsoNegotiates(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.VariantAlsoNegotiates); } /// /// Returns a result indicating the server is unable to store the representation needed to complete the request. /// Corresponds to HTTP status code 507 Insufficient Storage. /// public static Result InsufficientStorage(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.InsufficientStorage); } /// /// Returns a result indicating the server detected an infinite loop while processing a request with depth: infinity. Usually encountered in WebDAV scenarios. /// Corresponds to HTTP status code 508 Loop Detected. /// public static Result LoopDetected(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.LoopDetected); } /// /// Returns a result indicating further extensions to the request are required for the server to fulfill it. /// Corresponds to HTTP status code 510 Not Extended. /// public static Result NotExtended(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.NotExtended); } /// /// Returns a result indicating the client needs to authenticate to gain network access. /// Corresponds to HTTP status code 511 Network Authentication Required. /// public static Result NetworkAuthenticationRequired(params string [] messages) { return new Result(false, [..messages], HttpStatusCode.NetworkAuthenticationRequired); } } public partial class Result : Result { /// /// Returns a result indicating the server encountered an unexpected condition that prevented it from fulfilling the request. /// Corresponds to HTTP status code 500 Internal Server Error. /// public static Result InternalServerError(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.InternalServerError); } /// /// Returns a result indicating the server does not support the functionality required to fulfill the request. /// Corresponds to HTTP status code 501 Not Implemented. /// public static Result NotImplemented(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.NotImplemented); } /// /// Returns a result indicating the server, while acting as a gateway or proxy, received an invalid response from the upstream server. /// Corresponds to HTTP status code 502 Bad Gateway. /// public static Result BadGateway(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.BadGateway); } /// /// Returns a result indicating the server is currently unable to handle the request due to temporary overload or maintenance of the server. /// Corresponds to HTTP status code 503 Service Unavailable. /// public static Result ServiceUnavailable(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.ServiceUnavailable); } /// /// Returns a result indicating the server, while acting as a gateway or proxy, did not receive a timely response from the upstream server. /// Corresponds to HTTP status code 504 Gateway Timeout. /// public static Result GatewayTimeout(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.GatewayTimeout); } /// /// Returns a result indicating the server does not support the HTTP protocol version used in the request. /// Corresponds to HTTP status code 505 HTTP Version Not Supported. /// public static Result HttpVersionNotSupported(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.HttpVersionNotSupported); } /// /// Returns a result indicating the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process. /// Corresponds to HTTP status code 506 Variant Also Negotiates. /// public static Result VariantAlsoNegotiates(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.VariantAlsoNegotiates); } /// /// Returns a result indicating the server is unable to store the representation needed to complete the request. /// Corresponds to HTTP status code 507 Insufficient Storage. /// public static Result InsufficientStorage(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.InsufficientStorage); } /// /// Returns a result indicating the server detected an infinite loop while processing a request with depth: infinity. Usually encountered in WebDAV scenarios. /// Corresponds to HTTP status code 508 Loop Detected. /// public static Result LoopDetected(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.LoopDetected); } /// /// Returns a result indicating further extensions to the request are required for the server to fulfill it. /// Corresponds to HTTP status code 510 Not Extended. /// public static Result NotExtended(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.NotExtended); } /// /// Returns a result indicating the client needs to authenticate to gain network access. /// Corresponds to HTTP status code 511 Network Authentication Required. /// public static Result NetworkAuthenticationRequired(T? value, params string [] messages) { return new Result(value, false, [..messages], HttpStatusCode.NetworkAuthenticationRequired); } }