lucabriguglia / OpenCQRS

.NET Standard framework to create simple and clean design. Advanced features for DDD, CQRS and Event Sourcing.
Apache License 2.0
3 stars 115 forks source link

Custom handler or service #98

Closed lucabriguglia closed 4 years ago

lucabriguglia commented 4 years ago

I'm adding the option to use a custom handler or service instead of the default command handler that needs to implement the default command handler interface:

var command = new CreateProduct
{
    Name = Product.Name,
    Description = Product.Description,
    Price = Product.Price
};

// Option 1 - The dispatcher will automatically resolve the command handler (ICommandHandlerAsync<CreateProduct>)
await _dispatcher.SendAsync(command);

// Option 2 - Use your custom command handler or service
await _dispatcher.SendAsync(command, () => _productService.CreateProductAsync(command));
lucabriguglia commented 4 years ago

Released in v2.4.