-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Analyzer rules for writing Api classes
- Loading branch information
1 parent
17a3aba
commit 6c6fcd4
Showing
27 changed files
with
2,144 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Common; | ||
using Infrastructure.WebApi.Interfaces; | ||
|
||
namespace Infrastructure.WebApi.Common; | ||
|
||
/// <summary> | ||
/// Defines an callback that relates a <see cref="PostResult{TResponse}" /> containing a | ||
/// <see cref="TResource" /> | ||
/// </summary> | ||
// ReSharper disable once UnusedTypeParameter | ||
public delegate Result<PostResult<TResponse>, Error> ApiPostResult<TResource, TResponse>() | ||
where TResource : class where TResponse : IWebResponse; | ||
|
||
/// <summary> | ||
/// Defines an callback that relates a <see cref="TResponse" /> containing a | ||
/// <see cref="TResource" /> | ||
/// </summary> | ||
// ReSharper disable once UnusedTypeParameter | ||
public delegate Result<TResponse, Error> ApiResult<TResource, TResponse>() | ||
where TResource : class where TResponse : IWebResponse; | ||
|
||
/// <summary> | ||
/// Defines an callback that relates a <see cref="EmptyResponse" /> | ||
/// </summary> | ||
public delegate Result<EmptyResponse, Error> ApiEmptyResult(); | ||
|
||
/// <summary> | ||
/// Provides a container with a <see cref="TResponse" /> and other attributes describing a | ||
/// </summary> | ||
/// <typeparam name="TResponse"></typeparam> | ||
public class PostResult<TResponse> | ||
where TResponse : IWebResponse | ||
{ | ||
public PostResult(TResponse response, string? location = null) | ||
{ | ||
Response = response; | ||
Location = location; | ||
} | ||
|
||
public string? Location { get; } | ||
|
||
public TResponse Response { get; } | ||
|
||
/// <summary> | ||
/// Converts the <see cref="response" /> into a <see cref="PostResult{TResponse}" /> | ||
/// </summary> | ||
public static implicit operator PostResult<TResponse>(TResponse response) | ||
{ | ||
return new PostResult<TResponse>(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.