Ir al contenido

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.

Primeros Pasos con EricksonLopez.Events

dotnet add package EricksonLopez.Events --version 2.0.0
using System;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Events.Attributes;
using EricksonLopez.Events.Bus.Extensions;
using EricksonLopez.Events.Contracts;
using EricksonLopez.Events.Identifiers;
using Microsoft.Extensions.DependencyInjection;
namespace Example.EventsQuickStart;
[EventName("orders.placed")]
[EventVersion(1)]
[EventSource("orders-service")]
public sealed record OrderPlacedEvent(Guid OrderId, decimal Total) : IDomainEvent
{
public EventId Id { get; } = EventId.New();
public DateTimeOffset OccurredAt { get; } = DateTimeOffset.UtcNow;
}
public sealed class OrderPlacedHandler : IEventHandler<OrderPlacedEvent>
{
public ValueTask HandleAsync(OrderPlacedEvent @event, CancellationToken cancellationToken = default)
{
return ValueTask.CompletedTask;
}
}
public static class EventsBootstrap
{
public static void Register(IServiceCollection services)
{
services.AddEventBus();
services.AddEventHandler<OrderPlacedEvent, OrderPlacedHandler>();
}
}