tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
AuthorityResponse{TResult}.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics.CodeAnalysis;
3using System.Linq.Expressions;
4
5using Microsoft.AspNetCore.Mvc;
7
9{
14 public sealed class AuthorityResponse<TResult> : AuthorityResponse
15 {
19 public static Expression<Func<TResult, AuthorityResponse<TResult>>> MappingExpression { get; }
20
22 [MemberNotNullWhen(true, nameof(IsNoContent))]
23 public override bool Success => base.Success;
24
28 [MemberNotNullWhen(false, nameof(Result))]
29 [MemberNotNullWhen(false, nameof(Result))]
30 public bool? IsNoContent => Success ? Result == null : null;
31
35 public TResult? Result { get; private init; }
36
41
46 {
48 {
49 Result = result,
50 };
51 }
52
59 : base(errorMessage, httpResponse)
60 {
61 }
62
68 public AuthorityResponse(TResult result, HttpSuccessResponse httpResponse = HttpSuccessResponse.Ok)
69 {
70 Result = result ?? throw new ArgumentNullException(nameof(result));
71 SuccessResponse = httpResponse;
72 }
73
79 {
80 }
81 }
82}
Represents an error message returned by the server.
virtual bool Success
Checks if the AuthorityResponse was successful.
static Expression< Func< TResult, AuthorityResponse< TResult > > > MappingExpression
An expression to convert a TResult into an AuthorityResponse<TResult>. The resulting AuthorityRespon...
AuthorityResponse(ErrorMessageResponse errorMessage, HttpFailureResponse httpResponse)
Initializes a new instance of the AuthorityResponse<TResult> class.
AuthorityResponse(TResult result, HttpSuccessResponse httpResponse=HttpSuccessResponse.Ok)
Initializes a new instance of the AuthorityResponse<TResult> class.
HttpSuccessResponse? SuccessResponse
The HttpSuccessResponse for generating the IActionResults.
static AuthorityResponse()
Initializes static members of the AuthorityResponse<TResult> class.
bool? IsNoContent
Checks if a the AuthorityResponse<TResult> is a no content result. Only set on Success.
AuthorityResponse()
Initializes a new instance of the AuthorityResponse<TResult> class.
HttpFailureResponse
Indicates the type of HTTP status code an failing AuthorityResponse should generate.
HttpSuccessResponse
Indicates the type of HTTP status code a successful AuthorityResponse<TResult> should generate.