using System.Net;
namespace MaksIT.Results;
public partial class Result {
#region Common Informational Responses
///
/// Returns a result indicating that the initial part of a request has been received and the client should continue with the request.
/// Corresponds to HTTP status code 100 Continue.
///
public static Result Continue(params string [] messages) {
return new Result(true, [..messages], HttpStatusCode.Continue);
}
///
/// Returns a result indicating that the server is switching to a different protocol as requested by the client.
/// Corresponds to HTTP status code 101 Switching Protocols.
///
public static Result SwitchingProtocols(params string [] messages) {
return new Result(true, [..messages], HttpStatusCode.SwitchingProtocols);
}
#endregion
#region Extended Or Less Common Informational Responses
///
/// Returns a result indicating that the server has received and is processing the request, but no response is available yet.
/// Corresponds to HTTP status code 102 Processing.
///
public static Result Processing(params string [] messages) {
return new Result(true, [..messages], HttpStatusCode.Processing);
}
///
/// Returns a result indicating that the server is sending information about early hints that may be used by the client to begin preloading resources while the server prepares a final response.
/// Corresponds to HTTP status code 103 Early Hints.
///
public static Result EarlyHints(params string [] messages) {
return new Result(true, [..messages], (HttpStatusCode)103); // Early Hints is not defined in HttpStatusCode enum, 103 is the official code
}
#endregion
}
public partial class Result : Result {
#region Common Informational Responses
///
/// Returns a result indicating that the initial part of a request has been received and the client should continue with the request.
/// Corresponds to HTTP status code 100 Continue.
///
public static Result Continue(T? value, params string [] messages) {
return new Result(value, true, [..messages], HttpStatusCode.Continue);
}
///
/// Returns a result indicating that the server is switching to a different protocol as requested by the client.
/// Corresponds to HTTP status code 101 Switching Protocols.
///
public static Result SwitchingProtocols(T? value, params string [] messages) {
return new Result(value, true, [..messages], HttpStatusCode.SwitchingProtocols);
}
#endregion
#region Extended Or Less Common Informational Responses
///
/// Returns a result indicating that the server has received and is processing the request, but no response is available yet.
/// Corresponds to HTTP status code 102 Processing.
///
public static Result Processing(T? value, params string [] messages) {
return new Result(value, true, [..messages], HttpStatusCode.Processing);
}
///
/// Returns a result indicating that the server is sending information about early hints that may be used by the client to begin preloading resources while the server prepares a final response.
/// Corresponds to HTTP status code 103 Early Hints.
///
public static Result EarlyHints(T? value, params string [] messages) {
return new Result(value, true, [..messages], (HttpStatusCode)103); // Early Hints is not defined in HttpStatusCode enum, 103 is the official code
}
#endregion
}