Skip to content

A simple library containing useful common result definitions and helpers

License

Notifications You must be signed in to change notification settings

devvelopi/Resulti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Resulti

A simple library containing useful common result definitions and helpers

Installation

dotnet add package Resulti.Core

Usage

Very straightforward usage.

Basic Result

using Resulti.Core.Results;
using Resulti.Core.Util;
...

// Empty result 
new Result();

// Result with data
new Result<string>("Hello world");

// Result with object initialisation
new Result<int>(5) 
{
    Id = "ID-007",
    Status = ResultStatus.Success
}

...

Http Result

using Resulti.Core.Results;
using Resulti.Core.Util;
...

// Http result with object initialisation
var data = new List<int> {1, 2, 3};
new HttpResult<List<int>>(data) 
{
    Id = "ID-007",
    Status = ResultStatus.Success,
    HttpCode = 200,
    Count = data.Count
}

...

Extensions Usage

There are a number of utility extensions similar to the 'builder' functions used to make building results more streamlined in the case where long running builds aren't required. All of the following can also be achieved with object initialisation.

// Sets the result to successful
new Result().Success();

// Sets the result to successful with data
new Result<long>().Success(10);

// Sets the result to failed 
new Result().Failure();

// Sets the result to failed and clears data
new Result<long>().Failure()

// Adds a basic notification to the result
new Result().AddNotification("Result happened!");

// Adds a full notification to the result
new Result().AddNotification("Display message", NotificationType.Warning, "Developer message", "CODE123");

// Chains a result in a builder
new Result().Success()
    .AddNotification("Was successful!")
    .AddNotification("But just a warning", NotificationType.Warning);

About

A simple library containing useful common result definitions and helpers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages