Giter Site home page Giter Site logo

mediatr.commandbus.abstractions's Introduction

MediatR.CommandBus.Abstractions

Purpose

The sole intention of this library, is to provide more explict abstractions around common Command Bus objects, such as ICommand, IQuery, and IEvent to MediatR in an unobtrusive way.

Installation

This project is exposed as a NuGet package for your convenience. If you would like more information on installing the NuGet package, please refer to the installation section of the Wiki.

Target Frameworks

You can use this in your .Net Framework, .Net Standard, and .Net Core apps that are, or are planning, to use MediatR.

Example Usage

These interfaces and implementations are just wrappers around the base IRequest and IRequestHandler interfaces that MediatR provides.

Notice, in the Command example below, where we simple inherit from ICommand and ICommandHandler instead of IRequest and IRequestHandler respectively.

Command

public class SetCustomerInactiveCommand : ICommand<Customer>
{
    public Customer Customer { get; set; }
}

Command Handler

public class SetCustomerInactiveCommandHandler : ICommandHandler<SetCustomerInactiveCommand, Customer>
{
    private readonly ICustomerCommandRepository repository;

    public Handler(ICustomerCommandRepository repository)
    {
        this.repository = repository;
    }

    public async Task<Customer> Handle(SetCustomerInactiveCommand command, CancellationToken cancellationToken)
    {
        command.Customer.IsActive = false;

        return await this.repository.UpdateAsync(command.Customer.Id, command.Customer, cancellationToken);
    }
}

Command Invocation

var command = new new SetCustomerInactiveCommand { Customer = someCustomer };

await Mediator.Send(command);

Want More?

For more examples, and to try this out for yourself, clone or download the repository and look at the solution in the tests folder.

For more information, please check out the Wiki.

mediatr.commandbus.abstractions's People

Contributors

korz 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.