Pargoon.Core 1.2.0

Suggested Alternatives

Pargoon.Core 1.2.1

Additional Details

deprecated, int the next version added classes for sort and list request

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pargoon.Core --version 1.2.0                
NuGet\Install-Package Pargoon.Core -Version 1.2.0                
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="Pargoon.Core" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pargoon.Core --version 1.2.0                
#r "nuget: Pargoon.Core, 1.2.0"                
#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 Pargoon.Core as a Cake Addin
#addin nuget:?package=Pargoon.Core&version=1.2.0

// Install Pargoon.Core as a Cake Tool
#tool nuget:?package=Pargoon.Core&version=1.2.0                

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

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.

Add JsonConvert on top of system.text.json with default serilizing and deserializing camelCase,CaseInsensitive and UnsafeRelaxedJsonEscaping options