Pargoon.Core
1.1.9
deprecated
See the version list below for details.
dotnet add package Pargoon.Core --version 1.1.9
NuGet\Install-Package Pargoon.Core -Version 1.1.9
<PackageReference Include="Pargoon.Core" Version="1.1.9" />
paket add Pargoon.Core --version 1.1.9
#r "nuget: Pargoon.Core, 1.1.9"
// Install Pargoon.Core as a Cake Addin #addin nuget:?package=Pargoon.Core&version=1.1.9 // Install Pargoon.Core as a Cake Tool #tool nuget:?package=Pargoon.Core&version=1.1.9
Pargoon.Core
Pargoon.Core is a .NET library that provides a set of utility classes for managing operation results in applications. The library offers a standardized mechanism for handling success and failure statuses, along with associated data and error messages, using the TResult
and PocoResult
classes.
Features
- PocoResult Class: A base class that includes the status code (
StatusCode
), a numeric code (Code
), and a description (Description
). - TResult Class: The main class used to manage operation results, which can be initialized directly or using an HTTP status code.
- Derived Classes: Specific classes like
BadRequestDataResult
,UnauthorizedDataResult
, etc., designed to handle specific HTTP statuses. - TResult<T>: A generic version of
TResult
that also holds data related to the operation, in addition to managing the status.
Installation
To install this library, you can use the NuGet Package Manager in Visual Studio:
Install-Package Pargoon.Core
Or via the .NET CLI:
dotnet add package Pargoon.Core
Usage
After installation, you can use the classes provided by this library to manage operation results in your applications. Below are some examples:
Using the TResult
Class
using Pargoon.Core;
public class Example
{
public TResult ProcessData(int value)
{
if (value < 0)
{
return new BadRequestDataResult("Value cannot be negative");
}
return new TResult(200, "Processing successful");
}
public void Run()
{
var result = ProcessData(10);
if (result.IsSuccess)
{
Console.WriteLine("Success: " + result.Description);
}
else
{
Console.WriteLine("Failure: " + result.Description);
}
}
}
Using the TResult<T>
Class
using Pargoon.Core;
public class Example
{
public TResult<string> ProcessData(string input)
{
if (string.IsNullOrEmpty(input))
{
return TResult<string>.Fail(400, "Input cannot be null or empty");
}
return TResult<string>.Success(input.ToUpper(), "Data processed successfully");
}
public void Run()
{
var result = ProcessData("hello");
if (result.IsSuccess)
{
Console.WriteLine("Processed Data: " + result.Data);
}
else
{
Console.WriteLine("Error: " + result.Description);
}
}
}
Derived Classes
Pargoon.Core includes several derived classes from TResult
, specifically designed to handle common HTTP statuses:
BadRequestDataResult
: For handling HTTP 400 Bad Request.UnauthorizedDataResult
: For handling HTTP 401 Unauthorized.ForbiddenDataResult
: For handling HTTP 403 Forbidden.NotFoundDataResult
: For handling HTTP 404 Not Found.InternalServerErrorResult
: For handling HTTP 500 Internal Server Error.
These classes allow you to easily manage different statuses and provide appropriate error messages.
Contribution
Contributions are welcome! If you find a bug, have a feature request, or want to contribute to the project, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License. For more details, see the LICENSE file.
Contact
For any questions or support, please reach out to Navid Faridi.
This README.md
provides an overview of the Pargoon.Core library, including explanations, usage instructions, and contribution guidelines.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Text.Json (>= 8.0.4)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Pargoon.Core:
Package | Downloads |
---|---|
Noyanet.AuthService.ApiClient
Package Description |
|
Pargoon.Extensions.Linq
Pargoon.Extensions.Linq provides various helpful linq extensions for IQueryable. |
|
Pargoon.Exceptions
Pargoon.Exceptions is a .NET Standard library that provides custom exception handling classes for managing errors in a consistent and structured way. This library includes classes such as AppError for defining error details and AppException for handling exceptions with additional context like HTTP status codes and custom error codes. |
|
Noyan.ShadMessage.ApiContracts
Package Description |
|
PishgamSMSHelper
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 253 | 11/16/2024 | |
1.2.5 | 566 | 10/9/2024 | |
1.2.4 | 221 | 9/28/2024 | |
1.2.3 | 262 | 9/25/2024 | |
1.2.2 | 989 | 9/9/2024 | |
1.2.1 | 350 | 8/26/2024 | |
1.2.0 | 301 | 8/26/2024 | |
1.1.9 | 415 | 8/21/2024 | |
1.1.8 | 153 | 8/21/2024 | |
1.1.7 | 231 | 8/18/2024 | |
1.1.6 | 162 | 8/16/2024 | |
1.1.5 | 197 | 8/11/2024 | |
1.1.4 | 140 | 8/11/2024 | |
1.1.3 | 311 | 5/1/2024 | |
1.1.2 | 119 | 5/1/2024 | |
1.0.1 | 164 | 4/3/2024 | |
1.0.0 | 163 | 4/3/2024 |
Add JsonConvert on top of system.text.json with default serilizing and deserializing camelCase,CaseInsensitive and UnsafeRelaxedJsonEscaping options