diff --git a/src/MaksIT.Results/Result.Succes.cs b/src/MaksIT.Results/Result.Succes.cs index 8880f21..bbcb46e 100644 --- a/src/MaksIT.Results/Result.Succes.cs +++ b/src/MaksIT.Results/Result.Succes.cs @@ -9,150 +9,150 @@ public partial class Result { /// Returns a result indicating the request was successful and the server returned the requested data. /// Corresponds to HTTP status code 200 OK. /// - public static Result Ok(string message) => - Ok(new List { message }); + public static Result Ok(string? message) => + Ok(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server returned the requested data. /// Corresponds to HTTP status code 200 OK. /// - public static Result Ok(List messages) { - return new Result(true, messages, HttpStatusCode.OK); + public static Result Ok(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.OK); } /// /// Returns a result indicating the request was successful and a new resource was created. /// Corresponds to HTTP status code 201 Created. /// - public static Result Created(string message) => - Created(new List { message }); + public static Result Created(string? message) => + Created(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and a new resource was created. /// Corresponds to HTTP status code 201 Created. /// - public static Result Created(List messages) { - return new Result(true, messages, HttpStatusCode.Created); + public static Result Created(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.Created); } /// /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Corresponds to HTTP status code 202 Accepted. /// - public static Result Accepted(string message) => - Accepted(new List { message }); + public static Result Accepted(string? message) => + Accepted(message != null ? [message] : null); /// /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Corresponds to HTTP status code 202 Accepted. /// - public static Result Accepted(List messages) { - return new Result(true, messages, HttpStatusCode.Accepted); + public static Result Accepted(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.Accepted); } /// /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Corresponds to HTTP status code 203 Non-Authoritative Information. /// - public static Result NonAuthoritativeInformation(string message) => - NonAuthoritativeInformation(new List { message }); + public static Result NonAuthoritativeInformation(string? message) => + NonAuthoritativeInformation(message != null ? [message] : null); /// /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Corresponds to HTTP status code 203 Non-Authoritative Information. /// - public static Result NonAuthoritativeInformation(List messages) { - return new Result(true, messages, HttpStatusCode.NonAuthoritativeInformation); + public static Result NonAuthoritativeInformation(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation); } /// /// Returns a result indicating the request was successful but there is no content to send in the response. /// Corresponds to HTTP status code 204 No Content. /// - public static Result NoContent(string message) => - ResetContent(new List { message }); + public static Result NoContent(string? message) => + ResetContent(message != null ? [message] : null); /// /// Returns a result indicating the request was successful but there is no content to send in the response. /// Corresponds to HTTP status code 204 No Content. /// - public static Result NoContent(List messages) { - return new Result(true, messages, HttpStatusCode.NoContent); + public static Result NoContent(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.NoContent); } /// /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Corresponds to HTTP status code 205 Reset Content. /// - public static Result ResetContent(string message) => - ResetContent(new List { message }); + public static Result ResetContent(string? message) => + ResetContent(message != null ? [message] : null); /// /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Corresponds to HTTP status code 205 Reset Content. /// - public static Result ResetContent(List messages) { - return new Result(true, messages, HttpStatusCode.ResetContent); + public static Result ResetContent(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.ResetContent); } /// /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Corresponds to HTTP status code 206 Partial Content. /// - public static Result PartialContent(string message) => - PartialContent(new List { message }); + public static Result PartialContent(string? message) => + PartialContent(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Corresponds to HTTP status code 206 Partial Content. /// - public static Result PartialContent(List messages) { - return new Result(true, messages, HttpStatusCode.PartialContent); + public static Result PartialContent(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.PartialContent); } /// /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Corresponds to HTTP status code 207 Multi-Status. /// - public static Result MultiStatus(string message) => - MultiStatus(new List { message }); + public static Result MultiStatus(string? message) => + MultiStatus(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Corresponds to HTTP status code 207 Multi-Status. /// - public static Result MultiStatus(List messages) { - return new Result(true, messages, HttpStatusCode.MultiStatus); + public static Result MultiStatus(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.MultiStatus); } /// /// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Corresponds to HTTP status code 208 Already Reported. /// - public static Result AlreadyReported(string message) => - AlreadyReported(new List { message }); + public static Result AlreadyReported(string? message) => + AlreadyReported(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Corresponds to HTTP status code 208 Already Reported. /// - public static Result AlreadyReported(List messages) { - return new Result(true, messages, HttpStatusCode.AlreadyReported); + public static Result AlreadyReported(List? messages) { + return new Result(true, messages ?? [], HttpStatusCode.AlreadyReported); } /// /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Corresponds to HTTP status code 226 IM Used. /// - public static Result IMUsed(string message) => - IMUsed(new List { message }); + public static Result IMUsed(string? message) => + IMUsed(message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Corresponds to HTTP status code 226 IM Used. /// - public static Result IMUsed(List messages) { - return new Result(true, messages, (HttpStatusCode)226); // 226 is the official status code for IM Used + public static Result IMUsed(List? messages) { + return new Result(true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used } } public partial class Result : Result { @@ -161,149 +161,149 @@ public partial class Result : Result { /// Returns a result indicating the request was successful and the server returned the requested data. /// Corresponds to HTTP status code 200 OK. /// - public static Result Ok(T? value, string message) => - Ok(value, new List { message }); + public static Result Ok(T? value, string? message) => + Ok(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server returned the requested data. /// Corresponds to HTTP status code 200 OK. /// - public static Result Ok(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.OK); + public static Result Ok(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.OK); } /// /// Returns a result indicating the request was successful and a new resource was created. /// Corresponds to HTTP status code 201 Created. /// - public static Result Created(T? value, string message) => - Created(value, new List { message }); + public static Result Created(T? value, string? message) => + Created(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and a new resource was created. /// Corresponds to HTTP status code 201 Created. /// - public static Result Created(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.Created); + public static Result Created(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.Created); } /// /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Corresponds to HTTP status code 202 Accepted. /// - public static Result Accepted(T? value, string message) => - Accepted(value, new List { message }); + public static Result Accepted(T? value, string? message) => + Accepted(value, message != null ? [message] : null); /// /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Corresponds to HTTP status code 202 Accepted. /// - public static Result Accepted(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.Accepted); + public static Result Accepted(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.Accepted); } /// /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Corresponds to HTTP status code 203 Non-Authoritative Information. /// - public static Result NonAuthoritativeInformation(T? value, string message) => - NonAuthoritativeInformation(value, new List { message }); + public static Result NonAuthoritativeInformation(T? value, string? message) => + NonAuthoritativeInformation(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Corresponds to HTTP status code 203 Non-Authoritative Information. /// - public static Result NonAuthoritativeInformation(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.NonAuthoritativeInformation); + public static Result NonAuthoritativeInformation(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation); } /// /// Returns a result indicating the request was successful but there is no content to send in the response. /// Corresponds to HTTP status code 204 No Content. /// - public static Result NoContent(T? value, string message) => - NoContent(value, new List { message }); + public static Result NoContent(T? value, string? message) => + NoContent(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful but there is no content to send in the response. /// Corresponds to HTTP status code 204 No Content. /// - public static Result NoContent(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.NoContent); + public static Result NoContent(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.NoContent); } /// /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Corresponds to HTTP status code 205 Reset Content. /// - public static Result ResetContent(T? value, string message) => - ResetContent(value, new List { message }); + public static Result ResetContent(T? value, string? message) => + ResetContent(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Corresponds to HTTP status code 205 Reset Content. /// - public static Result ResetContent(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.ResetContent); + public static Result ResetContent(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.ResetContent); } /// /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Corresponds to HTTP status code 206 Partial Content. /// - public static Result PartialContent(T? value, string message) => - PartialContent(value, new List { message }); + public static Result PartialContent(T? value, string? message) => + PartialContent(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Corresponds to HTTP status code 206 Partial Content. /// - public static Result PartialContent(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.PartialContent); + public static Result PartialContent(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.PartialContent); } /// /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Corresponds to HTTP status code 207 Multi-Status. /// - public static Result MultiStatus(T? value, string message) => - MultiStatus(value, new List { message }); + public static Result MultiStatus(T? value, string? message) => + MultiStatus(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Corresponds to HTTP status code 207 Multi-Status. /// - public static Result MultiStatus(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.MultiStatus); + public static Result MultiStatus(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.MultiStatus); } /// /// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Corresponds to HTTP status code 208 Already Reported. /// - public static Result AlreadyReported(T? value, string message) => - AlreadyReported(value, new List { message }); + public static Result AlreadyReported(T? value, string? message) => + AlreadyReported(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Corresponds to HTTP status code 208 Already Reported. /// - public static Result AlreadyReported(T? value, List messages) { - return new Result(value, true, messages, HttpStatusCode.AlreadyReported); + public static Result AlreadyReported(T? value, List? messages) { + return new Result(value, true, messages ?? [], HttpStatusCode.AlreadyReported); } /// /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Corresponds to HTTP status code 226 IM Used. /// - public static Result IMUsed(T? value, string message) => - IMUsed(value, new List { message }); + public static Result IMUsed(T? value, string? message) => + IMUsed(value, message != null ? [message] : null); /// /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Corresponds to HTTP status code 226 IM Used. /// - public static Result IMUsed(T? value, List messages) { - return new Result(value, true, messages, (HttpStatusCode)226); // 226 is the official status code for IM Used + public static Result IMUsed(T? value, List? messages) { + return new Result(value, true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used } }