Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Generic publication methods to force using a non-abstract eve… #76

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Shared/DomainEventWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public object Unwrap(Type returnType)
}

public static DomainEventWrapper Wrap<T>(T domainEvent)
where T : IDomainEvent
where T : IDomainEvent, new()
{
var domainEventName = DomainEventNameCache.GetName<T>();
var domainEventSchema = DomainEventSchemaCache.GetEventSchema<T>();
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/DomainEventWrapperCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public DomainEventWrapperCollection(IEnumerable<DomainEventWrapper> domainEventW
public EventSchema DomainSchema { get; }

public static DomainEventWrapperCollection Create<T>(IEnumerable<T> domainEvents)
where T : IDomainEvent
where T : IDomainEvent, new()
{
var domainEventWrappers = domainEvents.Select(DomainEventWrapper.Wrap).ToArray();
if (domainEventWrappers.Select(x => x.DomainEventName).Distinct().Count() > 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class DomainEventNameCache
private static readonly ConcurrentDictionary<Type, string> DomainEventNameTypeMappings = new ConcurrentDictionary<Type, string>();

public static string GetName<T>()
where T : IDomainEvent
where T : IDomainEvent, new()
{
return GetName(typeof(T));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class DomainEventSchemaCache
private static readonly ConcurrentDictionary<Type, EventSchema> DomainEventSchemaTypeMappings = new ConcurrentDictionary<Type, EventSchema>();

public static EventSchema GetEventSchema<T>()
where T : IDomainEvent
where T : IDomainEvent, new()
{
return GetEventSchema(typeof(T));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ namespace Workleap.DomainEventPropagation;
public interface IEventPropagationClient
{
Task PublishDomainEventAsync<T>(T domainEvent, CancellationToken cancellationToken)
where T : IDomainEvent;
where T : IDomainEvent, new();

Task PublishDomainEventsAsync<T>(IEnumerable<T> domainEvents, CancellationToken cancellationToken)
where T : IDomainEvent;
where T : IDomainEvent, new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ private static DomainEventsHandlerDelegate BuildPipeline(DomainEventsHandlerDele
}

public Task PublishDomainEventAsync<T>(T domainEvent, CancellationToken cancellationToken)
where T : IDomainEvent
where T : IDomainEvent, new()
=> this.PublishDomainEventsAsync(new[] { domainEvent }, cancellationToken);

public async Task PublishDomainEventsAsync<T>(IEnumerable<T> domainEvents, CancellationToken cancellationToken)
where T : IDomainEvent
where T : IDomainEvent, new()
{
if (domainEvents == null)
{
Expand Down