ManagedCode.Communication
8.0.2
Prefix Reserved
See the version list below for details.
dotnet add package ManagedCode.Communication --version 8.0.2
NuGet\Install-Package ManagedCode.Communication -Version 8.0.2
<PackageReference Include="ManagedCode.Communication" Version="8.0.2" />
paket add ManagedCode.Communication --version 8.0.2
#r "nuget: ManagedCode.Communication, 8.0.2"
// Install ManagedCode.Communication as a Cake Addin #addin nuget:?package=ManagedCode.Communication&version=8.0.2 // Install ManagedCode.Communication as a Cake Tool #tool nuget:?package=ManagedCode.Communication&version=8.0.2
Communication
The Communication library is a convenient wrapper for handling the results of functions that do not throw exceptions. Instead of throwing exceptions, these functions return an object that contains the result of the operation. This makes it easy to handle and process the results of these operations in a consistent, reliable way.
Motivation
Many functions in software development can fail and throw exceptions when something goes wrong. This can make it difficult to handle errors and to read and understand code that uses these functions.
Exceptions are a powerful tool for handling error conditions in your code, but they can also be difficult to manage and can make your code harder to read and understand. Instead of throwing exceptions, the Communication library allows you to return a Result object that contains the result of an operation. This makes it easy to handle and process the results of these operations in a consistent, reliable way.
Features
- Wraps the result of a function in an object, eliminating the need to handle exceptions.
- Makes it easy to check whether the function was successful or not.
- Provides access to the function's output via simple property accessors.
Getting Started
To use the Communication library in your project, you will need to add a reference to the Communication assembly. You can do this by downloading the library from GitHub and adding it to your project, or by installing the Communication NuGet package.
Once you have added a reference to the Communication assembly, you can start using the library in your code. Here is a simple example of how to use the Communication library to handle the result of an operation:
var succeed = Result.Succeed();
if(succeed.IsSuccess)
{
// do some
}
var fail = Result.Fail();
if(fail.IsFailed)
{
// do some
}
Generic Result
var succeed = Result<MyObject>.Succeed(new MyObject());
if(succeed.IsSuccess)
{
succeed.Value // <-- this is the result
// do some
}
var fail = Result<MyObject>.Fail("Oops!");
if(fail.IsFailed)
{
// do some
}
Collection Result:
var collection = CollectionResult<int>.Succeed(Enumerable.Repeat(4, 100), 5, 100, 15000);
From:
var succeed = await Result<MyObject>.From(() => GetMyResult());
if(succeed.IsSuccess)
{
succeed.Value // <-- this is the result
// do some
}
Global handlers
Also we have global handlers for WebApi and SignalR
builder.Services.AddCommunication(option =>
{
option.ShowErrorDetails = true;
});
SignalR global hub filter
builder.Services.AddSignalR(options => options.AddCommunicationHubFilter());
WebApi middleware
app.UseCommunication();
Orleans
silo:
siloBuilder.UseOrleansCommunication();
client:
clientBuilder.UseOrleansCommunication();
Conclusion
In summary, our library provides a convenient and easy-to-use solution for handling the result of a function that may throw exceptions. It eliminates the need to handle exceptions and makes it easy to check whether the function was successful and to access its output. We hope you find it useful in your own projects!
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. |
-
net6.0
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net7.0
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages (14)
Showing the top 5 NuGet packages that depend on ManagedCode.Communication:
Package | Downloads |
---|---|
ManagedCode.Storage.Core
Base interfaces for ManagedCode.StorageS |
|
ManagedCode.Communication.Orleans
Communication for .NET |
|
ManagedCode.Storage.Azure
Storage for Azure |
|
ManagedCode.Storage.Aws
Storage for AWS |
|
ManagedCode.Storage.FileSystem
Storage for FileSystem |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.7 | 1,359 | 9/12/2024 |
8.0.6 | 1,236 | 6/29/2024 |
8.0.5 | 135 | 6/27/2024 |
8.0.4 | 142 | 6/27/2024 |
8.0.3 | 1,667 | 6/14/2024 |
8.0.2 | 330 | 6/13/2024 |
8.0.1 | 281 | 5/6/2024 |
8.0.0 | 2,216 | 11/29/2023 |
2.0.26 | 5,258 | 7/12/2023 |
2.0.25 | 1,290 | 6/6/2023 |
2.0.24 | 39,479 | 5/22/2023 |
2.0.23 | 3,713 | 5/21/2023 |
2.0.22 | 226 | 5/17/2023 |
2.0.21 | 232 | 5/17/2023 |
2.0.20 | 197 | 5/17/2023 |
2.0.19 | 7,449 | 3/15/2023 |
2.0.18 | 347 | 3/14/2023 |
2.0.17 | 304 | 3/12/2023 |
2.0.16 | 424 | 2/21/2023 |
2.0.15 | 741 | 2/17/2023 |
2.0.14 | 824 | 2/7/2023 |
2.0.13 | 7,093 | 12/19/2022 |
2.0.12 | 387 | 12/19/2022 |
2.0.11 | 421 | 12/8/2022 |
2.0.10 | 482 | 12/3/2022 |
2.0.9 | 338 | 11/24/2022 |
2.0.8 | 349 | 11/24/2022 |
2.0.7 | 367 | 11/24/2022 |
2.0.5 | 356 | 11/24/2022 |
2.0.3 | 349 | 11/24/2022 |
2.0.2 | 359 | 11/24/2022 |
2.0.1 | 370 | 11/24/2022 |
2.0.0 | 361 | 11/22/2022 |
1.0.3 | 2,550 | 11/1/2022 |
1.0.2 | 2,211 | 10/27/2022 |
1.0.1 | 414 | 10/26/2022 |
1.0.0 | 8,060 | 10/17/2022 |
0.1.2 | 13,352 | 8/11/2022 |
0.1.1 | 429 | 8/11/2022 |
0.1.0 | 423 | 8/11/2022 |
0.0.8 | 8,686 | 7/27/2022 |
0.0.7 | 437 | 7/27/2022 |
0.0.6 | 7,161 | 7/19/2022 |
0.0.5 | 452 | 7/19/2022 |
0.0.4 | 419 | 7/19/2022 |
0.0.3 | 2,231 | 7/16/2022 |
0.0.2 | 446 | 7/15/2022 |
0.0.1 | 442 | 7/15/2022 |