private void CallEvent(AccountEventArgs accountEventArgs, AccountSateHandler accountSateHandler) { if (accountEventArgs != null) { accountSateHandler?.Invoke(this, accountEventArgs); } }
public void Open(AccountType accountType, decimal sum, AccountSateHandler addSumHandler, AccountSateHandler withdrawSumHandler, AccountSateHandler calculetionHandler, AccountSateHandler closeAccountHandler, AccountSateHandler openAccountHandler) { T newAccount = null; switch (accountType) { case AccountType.Ordinary: { newAccount = new DemandAccount(sum, 1) as T; break; } case AccountType.Deposit: { newAccount = new DepositAccount(sum, 40) as T; break; } } if (newAccount == null) { throw new Exception("Ошибка создания счета"); } 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 += calculetionHandler; newAccount.Open(); }