C0deGeek.Result
2.0.3
dotnet add package C0deGeek.Result --version 2.0.3
NuGet\Install-Package C0deGeek.Result -Version 2.0.3
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="C0deGeek.Result" Version="2.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add C0deGeek.Result --version 2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: C0deGeek.Result, 2.0.3"
#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 C0deGeek.Result as a Cake Addin #addin nuget:?package=C0deGeek.Result&version=2.0.3 // Install C0deGeek.Result as a Cake Tool #tool nuget:?package=C0deGeek.Result&version=2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
C0deGeek.Result
C0deGeek.Result is a library for handling and chaining the results of operations in a functional style.
Features
Represents the result of an operation as a Result or Result<T> object.
Provides a fluent API for chaining operations and handling their results.
Distinguishes between different types of operation results, such as success, failure, and not found.
Usage
The following code snippets demonstrate the usage of this library:
using C0deGeek.Result;
using C0deGeek.Result.Extensions;
// ...
// Combine results
var combinedResult = Result.Ok()
.Combine(ValidateSomething(input))
.Combine(ValidateSomethingElse(input2));
// Throw on failure
combinedResult.ThrowFunctionalExceptionOnFailure();
// Extract value or throw on failure
var someClassValue = await GetSomeClassResult().GetValueOrThrowFunctionalException();
// On success, perform another operation
var finalResult = await GetSomeClassResult().OnSuccessAsync(value => PerformAnotherOperation(value));
Description of Methods
Combine
: The Combine extension method allows you to chain multiple operations together. If any operation fails, the rest are not executed.ThrowFunctionalExceptionOnFailure
: The ThrowFunctionalExceptionOnFailure extension method throws a FunctionalException if the result represents a failure.GetValueOrThrowFunctionalException
: The GetValueOrThrowFunctionalException extension method extracts the value from a Result<T> or throws a FunctionalException if the result represents a failure.OnSuccessAsync
: The OnSuccessAsync extension method allows you to chain another operation that should be performed only if the previous operation was successful.
Installation
Add a reference to the C0deGeek.Result NuGet package to your project.
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
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. |
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.