예제 #1
0
파일: Account.cs 프로젝트: MaksM1/-
 private void CallEvent(AccountEventArgs e, AccountStateHadler hadler)
 {
     if (e != null)
     {
         hadler?.Invoke(this, e);
     }
 }
예제 #2
0
파일: Bank.cs 프로젝트: MaksM1/-
        public void Open(AccountType accountType, decimal sum, AccountStateHadler addSumHandler, AccountStateHadler withdrawHadler,
                         AccountStateHadler calculationHandler, AccountStateHadler closeAccountHandler, AccountStateHadler openAccountHandler)
        {
            T newAccount = null;

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

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 30) as T;
                break;
            }
            if (newAccount == null)
            {
                throw new Exception("Ошибка создания счета.");
            }
            if (accounts == null)
            {
                accounts = new T[] { newAccount };
            }
            else
            {
                T[] tempAccount = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccount[i] = accounts[i];
                    tempAccount[tempAccount.Length - 1] = newAccount;
                }
            }

            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawHadler;
            newAccount.Calculated += calculationHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;

            newAccount.Open();
        }