// handle commands

            public static (Event Event, AccountState NewState) Debit
                (this AccountState @this, MakeTransfer transfer)
            {
                var evt      = transfer.ToEvent();
                var newState = @this.Apply(evt);

                return(evt, newState);
            }
            public static AccountState Apply(this AccountState @this, Event evt)
            => new Pattern <AccountState>
            {
                (DepositedCash e) => @this.Credit(e.Amount),
                (DebitedTransfer e) => @this.Debit(e.DebitedAmount),
                (FrozeAccount e) => @this.WithStatus(AccountStatus.Frozen),
            }

            .Match(evt);
 public static AccountState Apply(this AccountState acc, Event evt)
 => evt switch
 {
     (DepositedCash e) => acc with {
예제 #4
0
 public static AccountState Apply(this AccountState acc, Event evt)
 => evt switch
 {