Пример #1
0
        /// <summary>
        /// Initializes the instance of service.
        /// </summary>
        /// <param name="accountRepository">account repository service</param>
        /// <param name="accountIdService">account id service</param>
        /// <param name="accountCreater">account creation service</param>
        public AccountService(IAccountRepository accountRepository, AccountIdService accountIdService, IAccountCreater accountCreater)
        {
            VerifyInput(accountRepository, accountIdService, accountCreater);

            _accountRepository = accountRepository;
            _accountIdService  = accountIdService;
            _accountCreater    = accountCreater;

            try
            {
                _accounts.AddRange(_accountRepository.GetAccounts());
            }
            catch (Exception)
            {
                _accounts.Clear();
            }
        }
Пример #2
0
        private static void VerifyInput(IAccountRepository accountRepository, AccountIdService accountIdService, IAccountCreater accountCreater)
        {
            if (ReferenceEquals(accountRepository, null))
            {
                throw new ArgumentNullException(nameof(accountRepository));
            }

            if (ReferenceEquals(accountIdService, null))
            {
                throw new ArgumentNullException(nameof(accountIdService));
            }

            if (ReferenceEquals(accountCreater, null))
            {
                throw new ArgumentNullException(nameof(accountCreater));
            }
        }