Giter Club home page Giter Club logo

toolpack-domain-utils's Introduction

ToolPack Domain Utils

Useful opinionated domain components and/or helper functions for .NET solutions.

ToolPack.DomainUtils.Functional

Classes and interfaces to help with functional programming in C#.

Result<T>, Result, Error and Success

This is a simple implementation of the Result pattern in C#.

The package contains Result<T> and Result (i.e. Result<Success>) classes, used to represent the result of an operation that can succeed or fail:

  • In case of success, the Value property (of type T) will contain the successful output of the operation,
  • In case of failure, the Error property will contain the Error output of the operation.

The Error class represents operation errors with all their details.

Useful references:

Result extension methods

The package contains a set of extension methods to help with the handling of Result instances:

  • Execute/ExecuteAsync execute a Result function or action if the input result is successful, or return the initial Error in case of input failure;
  • Log methods log the output of the input Result instance, depending on the input result being a success or error;
  • Map/MapAsync methods apply functions of generic return type, depending on the input result being a success or error;
  • Pipe/PipeAsync methods apply a Result function to the Value of an input Result<T> instance if it is successful, or return the initial Error in case of input failure;
  • Switch/SwitchAsync methods run actions, depending on the input result being a success or error.

These methods are useful to chain operations and handle the output of each operation in a functional way.

They intend to help with the implementation of the Railway Oriented Programming (ROP) pattern.

Useful references:

toolpack-domain-utils's People

Contributors

nhpinheiro avatar nunohpinheiro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.