Beispiel #1
0
        public static bool CheckAccountName(string accountName, bool isForSummary, bool throwExceptionIfAccountNameIsInvalid)
        {
            if (string.IsNullOrEmpty(accountName))
            {
                if (isForSummary)
                {
                    return(true);
                }
                if (throwExceptionIfAccountNameIsInvalid)
                {
                    throw new ArgumentNullException("accountName");
                }
                return(false);
            }
            if (accountName.Length > 24 || accountName.Length < 3)
            {
                if (isForSummary)
                {
                    return(true);
                }
                if (throwExceptionIfAccountNameIsInvalid)
                {
                    throw new ArgumentOutOfRangeException("accountName", string.Format("accountName must be at least {0} characters and at most {1} characters", 3, 24));
                }
                return(false);
            }
            int accountNameInvalidChar = StorageStampHelpers.GetAccountNameInvalidChar(accountName);

            if (accountNameInvalidChar < 0)
            {
                return(true);
            }
            if (isForSummary)
            {
                return(true);
            }
            if (throwExceptionIfAccountNameIsInvalid)
            {
                throw new ArgumentOutOfRangeException("accountName", string.Format("The character '{0}' at index {1} is not allowed in the account name", StorageStampHelpers.MakeXmlFriendlyString(accountName[accountNameInvalidChar]), accountNameInvalidChar));
            }
            return(false);
        }