private void CallEvent(AccountEventArgs e, AccountStateHadler hadler) { if (e != null) { hadler?.Invoke(this, e); } }
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(); }