AutoDispatch.Templates
1.21.0
dotnet new install AutoDispatch.Templates@1.21.0
This package contains a .NET Template Package you can call from the shell/command line.
AutoDispatch.Templates
dotnet new item templates that scaffold code for
AutoDispatch.Generator:
a command + [Handler] pair, a notification + [NotificationHandler] pair, or a streaming
query + [StreamHandler] pair.
Install
dotnet new install AutoDispatch.Templates
Use
Command + Handler
dotnet new autodispatch-handler -n CreateOrder --namespace MyApp.Orders
Generates CreateOrderCommand.cs:
namespace MyApp.Orders;
public sealed record CreateOrderCommand(/* TODO: add command properties */ string Value);
[AutoDispatch.Handler]
public sealed class CreateOrderHandler
{
public System.Threading.Tasks.Task HandleAsync(CreateOrderCommand command, System.Threading.CancellationToken ct = default)
{
// TODO: implement handler logic.
throw new System.NotImplementedException();
}
}
Notification + NotificationHandler
dotnet new autodispatch-notification -n OrderCreated --namespace MyApp.Orders
Generates OrderCreatedNotification.cs:
namespace MyApp.Orders;
public sealed record OrderCreatedNotification(/* TODO: add notification properties */ string Value);
[AutoDispatch.NotificationHandler]
public sealed class OrderCreatedHandler
{
public System.Threading.Tasks.Task HandleAsync(OrderCreatedNotification notification, System.Threading.CancellationToken ct = default)
{
// TODO: implement handler logic.
throw new System.NotImplementedException();
}
}
Run the command again with a different -n to add another handler for the same
notification type — any number of [NotificationHandler] classes may subscribe to it.
Streaming query + StreamHandler
dotnet new autodispatch-stream -n GetOrders --namespace MyApp.Orders
Generates GetOrdersQuery.cs:
namespace MyApp.Orders;
public sealed record GetOrdersQuery(/* TODO: add query properties */ string Value);
[AutoDispatch.StreamHandler]
public sealed class GetOrdersHandler
{
public System.Collections.Generic.IAsyncEnumerable<object> HandleAsync(GetOrdersQuery query, System.Threading.CancellationToken ct = default)
{
// TODO: replace object with your result type, then reimplement this as an async iterator
// that yields items as they become available.
throw new System.NotImplementedException();
}
}
Uninstall
dotnet new uninstall AutoDispatch.Templates
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.