MFA.Result
8.0.0
See the version list below for details.
dotnet add package MFA.Result --version 8.0.0
NuGet\Install-Package MFA.Result -Version 8.0.0
<PackageReference Include="MFA.Result" Version="8.0.0" />
paket add MFA.Result --version 8.0.0
#r "nuget: MFA.Result, 8.0.0"
// Install MFA.Result as a Cake Addin
#addin nuget:?package=MFA.Result&version=8.0.0
// Install MFA.Result as a Cake Tool
#tool nuget:?package=MFA.Result&version=8.0.0
MFA.Result NuGet Package
Overview
MFA.Result
is a lightweight, versatile .NET library designed to simplify error handling and response management in your applications. It provides a robust way to encapsulate the results of operations, including success or failure information along with data and error messages. This library is ideal for APIs, web applications, and any .NET project that requires clear and concise result management.
Features
- Generic
Result<T>
class to handle operation outcomes with success or failure states. - Support for HTTP status codes to align with RESTful API response patterns.
- Implicit conversion operators for easy construction of
Result
objects. - Optional error messages list for detailed failure information.
Installation
To install MFA.Result
, use the NuGet Package Manager console:
Installation of MFA.Result
can be done using several methods as described below. Choose the one that best fits your development environment and workflow.
Using NuGet Package Manager Console
To install MFA.Result
via the NuGet Package Manager Console in Visual Studio, use the following command:
Install-Package MFA.Result -Version 8.0.0
Using NuGet CLI
If you prefer using the command line, NuGet CLI can be used to install MFA.Result
. First, ensure you have the NuGet CLI installed, then run the following command:
nuget install MFA.Result -Version 8.0.0
Using Visual Studio's NuGet Package Manager GUI
For those who prefer a graphical interface within Visual Studio:
- Open your solution in Visual Studio.
- Right-click on your project in the Solution Explorer and select
Manage NuGet Packages
. - Go to the
Browse
tab, search forMFA.Result
, select it, then pressInstall
. - Choose the version you wish to install if prompted.
These methods provide flexibility in how you can add MFA.Result
to your projects, depending on your preference for tooling and the environment.
Usage
Below are some examples of how to use the MFA.Result
library in your projects.
Successful Operation
public Result<string> GetUserName(int userId)
{
// Your logic here
return "John Doe"; // Implicitly converts to a successful Result
}
Operation With Error
public Result<string> GetUserName(int userId)
{
// Your logic here
return (HttpStatusCode.NotFound, "User not found");
}
Checking Operation Result
var result = GetUserName(1);
if (result.IsSuccessful)
{
Console.WriteLine(result.Data);
}
else
{
Console.WriteLine(result.ErrorMessages.FirstOrDefault());
}
Contributing
Contributions are welcome! If you have suggestions or want to improve MFA.Result
, please feel free to fork the repository, make changes, and submit a pull request.
License
MFA.Result
is available under the MIT license. See the LICENSE file for more info.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
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.