using System.Collections.Generic;
public static void Main()
var userEventsService = new UserEventsService();
Console.WriteLine("User Created Start");
userEventsService.RaiseEvent(new UserCreatedEvent("Mark"));
Console.WriteLine("User Created End");
Console.WriteLine("Manager Password Reset Start");
userEventsService.RaiseEvent(new AddManagerPasswordResetEvent("ABC", "Mark"));
Console.WriteLine("Manager Password Reset End");
public interface IDomainService
void RaiseEvent(IEvent @event);
public abstract class DomainEventsService : IDomainService
public virtual void RaiseEvent(IEvent @event)
Console.WriteLine("DomainEventsService - Type: " + @event.GetType() + " Object: " + JsonConvert.SerializeObject(@event));
public class UserEventsService : DomainEventsService
public override void RaiseEvent(IEvent @event)
public abstract class IEvent
public string UserId {get; set;}
public object Data { get; set; }
public IEvent (string userId)
public class UserCreatedEvent : IEvent
public UserCreatedEvent(string userId) : base (userId)
public class AddManagerPasswordResetEvent : IEvent
public AddManagerPasswordResetEvent (string userId, string affectedUserId) : base (userId)
Data = new Dictionary<string, string>
{"affectedUserId", affectedUserId}