Beispiel #1
0
        public static void CheckContainerName(string containerName, ContainerType containerType, bool isSummaryContainer)
        {
            int num;

            if (string.IsNullOrEmpty(containerName))
            {
                if (!isSummaryContainer)
                {
                    throw new ArgumentNullException("containerName");
                }
                return;
            }
            if (containerName.Length > 63 || containerName.Length < 3)
            {
                if (!isSummaryContainer)
                {
                    throw new XStoreArgumentOutOfRangeException("containerName", string.Format("containerName must be at least {0} characters and at most {1} characters", 3, 63), "The specified resource name length is not within the permissible limits.");
                }
                return;
            }
            if ((containerType == ContainerType.BlobContainer || containerType == ContainerType.FileContainer) && SpecialNames.IsBlobContainerSpecialName(containerName))
            {
                return;
            }
            if (containerType == ContainerType.TableContainer && SpecialNames.IsTableContainerSpecialName(containerName))
            {
                return;
            }
            num = (containerType != ContainerType.TableContainer ? StorageStampHelpers.GetContainerNameInvalidChar(containerName) : StorageStampHelpers.GetTableNameInvalidChar(containerName));
            if (num < 0)
            {
                return;
            }
            if (!isSummaryContainer)
            {
                throw new InvalidResourceNameException(string.Format("The character '{0}' at index {1} is not allowed in the container name", StorageStampHelpers.MakeXmlFriendlyString(containerName[num]), num));
            }
        }
Beispiel #2
0
        public static void ValidateStorageDomainLabel(string storageDomainLabel)
        {
            if (storageDomainLabel.Length < 1 || storageDomainLabel.Length > 63)
            {
                throw new ArgumentOutOfRangeException("storageDomainName", string.Format("The length {0} of the label {1} in storage domain name is invalid.", storageDomainLabel.Length, storageDomainLabel));
            }
            int invalidCharInName = StorageStampHelpers.GetInvalidCharInName(storageDomainLabel, StorageStampHelpers.DOMAIN_LABEL_ALLOWED_PATTERN, true);

            if (invalidCharInName >= 0)
            {
                throw new ArgumentOutOfRangeException("storageDomainName", string.Format("The character '{0}' at index {1} is not allowed in the storage domain label {2}", StorageStampHelpers.MakeXmlFriendlyString(storageDomainLabel[invalidCharInName]), invalidCharInName, storageDomainLabel));
            }
        }
Beispiel #3
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);
        }