Esempio n. 1
0
 private void CallEvent(AccountEvent e, StateAccHand handler)
 {
     if (e != null)
     {
         handler?.Invoke(this, e);
     }
 }
Esempio n. 2
0
        public void Open(Tepe Tepe, decimal sum,
                         StateAccHand addSumHandler, StateAccHand withdrawSumHandler,
                         StateAccHand calculationHandler, StateAccHand closeAccountHandler,
                         StateAccHand openAccountHandler)
        {
            T newAccount = null;

            switch (Tepe)
            {
            case Tepe.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case Tepe.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("error open acc");
            }
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }

            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;
            newAccount.Open();
        }