Ejemplo n.º 1
0
        private static void DomainStuff()
        {
            DomainEventsHandler.Register <AccountCreated>(CreateAccount);

            var account = new Account()
            {
                Id   = 1,
                Name = "My Account"
            };

            account.CreateNewAccount();
        }
        protected override void HandleMessageBegin(TMessageType message)
        {
            var messageType = message.GetType();

            if (!Handlers.ContainsKey(messageType))
            {
                return;
            }

            var handlers = Handlers[messageType];

            foreach (var handler in handlers)
            {
                DomainEventsHandler.Register(messageType, handler);
            }
        }
 public void DeleteAccount()
 {
     DomainEventsHandler.Raise(new AccountDeleted {
         Id = this.Id
     });
 }
 public void CreateNewAccount()
 {
     DomainEventsHandler.Raise(new AccountCreated {
         Id = this.Id, Name = this.Name
     });
 }
 protected override void HandleMessageEnd(TMessageType message)
 {
     DomainEventsHandler.ClearHandlers();
 }