Leon.Results 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Leon.Results --version 1.0.1                
NuGet\Install-Package Leon.Results -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Leon.Results" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Leon.Results --version 1.0.1                
#r "nuget: Leon.Results, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Leon.Results as a Cake Addin
#addin nuget:?package=Leon.Results&version=1.0.1

// Install Leon.Results as a Cake Tool
#tool nuget:?package=Leon.Results&version=1.0.1                

Leon.Results

Leon.Results is a .NET library that provides a simple and intuitive way to handle operation results, making it easier to manage success and failure cases, especially in scenarios involving validation, error handling, and return values.

Installation

You can install the Leon.Results package via NuGet Package Manager Console:

Install-Package Leon.Results

Or by adding it to your .csproj file:

<PackageReference Include="Leon.Results" Version="1.0.0" />

Usage

Basic Result Handling

The Result class is designed to indicate the outcome of an operation, whether it was successful or failed.

using Leon.Results;

// Creating a success result
Result successResult = Result.Success();

// Creating a failure result with error messages
Result failureResult = Result.Failure(new List<string> { "Error 1", "Error 2" });

if (successResult.IsSuccess)
{
    // Handle success
}
else
{
    // Handle failure and access error messages
    IEnumerable<string> errors = failureResult.Errors;
}

Result with Value

For operations that return a value upon success, you can use the Result<T> class.

using Leon.Results;

// Creating a success result with a value
Result<int> successWithValue = Result<int>.Success(42);

// Creating a failure result with error messages and no value
Result<int> failureWithValue = Result<int>.Failure(new List<string> { "Failed to compute value" });

if (successWithValue.IsSuccess)
{
    int value = successWithValue.Value;
    // Use the value
}
else
{
    // Handle failure and access error messages
    IEnumerable<string> errors = failureWithValue.Errors;
}

License

This project is licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
1.0.2 79 9/8/2024
1.0.1 100 9/7/2024
1.0.0 92 9/7/2024