예제 #1
0
        /// <summary> 根据 <see cref="IAccount.Name"/> 检查是否<b>不</b>存在相应的 <see cref="IAccount"/>. </summary>
        public static AccountNotExistsResult Check(IAccountManager accountManager, String accountName)
        {
            if (accountManager == null) throw new ArgumentNullException("accountManager");
            if (String.IsNullOrEmpty(accountName)) throw new ArgumentNullException("accountName");

            IAccount account = accountManager.FindAccountByName(accountName);
            if (account != null)
            {  
                var message = String.Format("Account for name [{0}] exists.", accountName);
                return new AccountNotExistsResult(false, message, account);
            }
            return new AccountNotExistsResult(true, null, null);
        }