using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
var events = new List<IEvent>(){
new Event{AccountId = 1, Name = "Event1"},
new Event{AccountId = 1, CorrelationId = Guid.NewGuid(), Name = "Event2"},
new Event{AccountId = 1, Name = "Event3"}
new EventPublisherProvider().Publish(events);
public class EventPublisherProvider{
public void Publish<T>(IEnumerable<T> eventObjects) where T : IAccountEvent, ICorrelatedEvent {
string jsonString = JsonSerializer.Serialize(eventObjects);
Console.WriteLine(jsonString);
public class Event : IEvent, IAccountEvent, ICorrelatedEvent {
public int AccountId {get;set;}
public Guid CorrelationId {get;set;}
public string Name {get;set;}
public interface IEvent { }
public interface ICorrelatedEvent {
Guid CorrelationId {get;set;}
public interface IAccountEvent {