Resultify 1.0.9
dotnet add package Resultify --version 1.0.9
NuGet\Install-Package Resultify -Version 1.0.9
<PackageReference Include="Resultify" Version="1.0.9" />
<PackageVersion Include="Resultify" Version="1.0.9" />
<PackageReference Include="Resultify" />
paket add Resultify --version 1.0.9
#r "nuget: Resultify, 1.0.9"
#:package Resultify@1.0.9
#addin nuget:?package=Resultify&version=1.0.9
#tool nuget:?package=Resultify&version=1.0.9
Resultify
Resultify is a C# library designed to handle and map responses with various categories and HTTP status codes. It provides a structured way to manage responses in your application, making it easier to handle success, error, and informational messages.
Features
- Response Handling: Manage responses with different categories such as Success, Information, Redirection, ClientError, ServerError, and GenericError.
- Response Mapping: Map responses to different types or values using custom mapping functions.
Installation
To install Resultify, you can use the NuGet package manager:
dotnet add package Resultify
Usage
Response Handling You can create a ResultifyHandler to handle different types of responses:
var handler = new ResultifyHandler<string>("Test Value", ResponseCategory.Success, "Success message", HttpStatusCode.OK);
Console.WriteLine(handler.Message); // Output: Success message
Response Mapping
Map responses to different types or values using the MapResponse method:
var handler = new ResultifyHandler<string>("Test Value", ResponseCategory.Success, "Success message", HttpStatusCode.OK);
var result = handler.MapResponse(value => value.Length);
Console.WriteLine(result.Value); // Output: Test Value
Error Handling
Handle different categories of responses:
// Sample method that returns a ResultifyHandler
public async Task<ResultifyHandler<int?>> Producer()
{
// Some work is done here
int? result = await AnotherComputedValue();
// Produce a response based on the result
if (result is null)
{
return Resultify.NotFound<int?>(HttpStatusCode.NotFound, "Value not found");
}
return Resultify.Success(result, HttpStatusCode.OK, "Optional message");
}
// MapResponse method can be used to map the response to a different type
public async Task<ResultifyHandler<ObjectDTO>> Producer2()
{
// Some work is done here
ResultifyHandler<DbObject?> result = await AnotherComputedValue();
return result.MapResponse(r => r.AsDTO());
}
// Sample method that consumes the ResultifyHandler
public async Task<int> Consumer()
{
var result = await Producer();
// Handle the response based on the category
if (result.Category == ResponseCategory.Success)
{
Console.WriteLine(result.Value);
}
else
{
Console.WriteLine(result.Message);
}
// Check multiple values
var objectDto = await Producer2();
if(Resultify.AnyFail(result, objectDto))
{
Console.WriteLine("At least one response is an error");
}
return Resultify.Success(result, HttpStatusCode.Ok);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.