Closed arakakivl closed 1 year ago
Something like this:
public interface IDomainNotificationHandler : INotificationHandler<DomainNotification> { public bool HasNotifications(); public DomainNotification? GetFirstPublishedNotification(); } public class DomainNotificationHandler : IDomainNotificationHandler { private readonly List<DomainNotification> _notifications; public IReadOnlyCollection<DomainNotification> Notifications => _notifications; public DomainNotificationHandler() { _notifications = new(); } public async Task Handle(DomainNotification notification, CancellationToken cancellationToken) { _notifications.Add(notification); await Task.CompletedTask; } public bool HasNotifications() => _notifications.Any(); public DomainNotification? GetFirstPublishedNotification() => _notifications.FirstOrDefault(); }
Is it possible?
Something like this:
Is it possible?