Example #1
0
 public static void CheckStorageDomainName(string storageDomainName)
 {
     if (string.IsNullOrEmpty(storageDomainName))
     {
         throw new ArgumentNullException("storageDomainName");
     }
     if (storageDomainName.Length > 255)
     {
         throw new ArgumentOutOfRangeException("storageDomainName", string.Concat("Storage domain name exceeds the maximum limit of ", 255));
     }
     char[]   sTORAGEDOMAINNAMELABELSEPARATORCHAR = new char[] { StorageStampHelpers.STORAGE_DOMAIN_NAME_LABEL_SEPARATOR_CHAR[0] };
     string[] strArrays = storageDomainName.Split(sTORAGEDOMAINNAMELABELSEPARATORCHAR);
     if ((int)strArrays.Length < 2)
     {
         throw new ArgumentException(string.Format("Storage domain {0} should have a valid top level domain and a label", storageDomainName), "storageDomainName");
     }
     string[] strArrays1 = strArrays;
     for (int i = 0; i < (int)strArrays1.Length; i++)
     {
         StorageStampHelpers.ValidateStorageDomainLabel(strArrays1[i]);
     }
 }
Example #2
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));
            }
        }
Example #3
0
 public void JustDecompileGenerated_set_IfNotModifiedSinceTime(DateTime?value)
 {
     this.ifNotModifiedSinceTime = StorageStampHelpers.AdjustNullableDatetimeRange(value);
 }
Example #4
0
 public void JustDecompileGenerated_set_IfLastModificationTimeMismatch(DateTime[] value)
 {
     this.ifLastModificationTimeMismatch = StorageStampHelpers.AdjustDateTimeRange(value);
 }
Example #5
0
 public override string ToString()
 {
     object[] objArray = new object[] { (this.IfModifiedSinceTime.HasValue ? this.IfModifiedSinceTime.Value.ToString("O") : "<null>"), (this.IfNotModifiedSinceTime.HasValue ? this.IfNotModifiedSinceTime.Value.ToString("O") : "<null>"), (this.ifLastModificationTimeMatch != null ? StorageStampHelpers.DateTimeArrayToString(this.ifLastModificationTimeMatch) : "<null>"), (this.ifLastModificationTimeMismatch != null ? StorageStampHelpers.DateTimeArrayToString(this.ifLastModificationTimeMismatch) : "<null>"), this.IsMultipleConditionalHeaderEnabled };
     return(string.Format("[ifModifiedSinceTime = {0}, ifNotModifiedSinceTime = {1}, ifLastModificationTimeMatch = {2}, ifLastModificationTimeMismatch = {3}, isMultipleConditionalHeaderEnabled = {4}]", objArray));
 }
Example #6
0
        private IEnumerator <IAsyncResult> SynchronousCopyBlobImpl(string sourceAccount, IBlobObject sourceBlob, DateTime?expiryTime, byte[] applicationMetadata, OverwriteOption overwriteOption, IBlobObjectCondition sourceCondition, IBlobObjectCondition destinationCondition, UriString copySource, AsyncIteratorContext <CopyBlobOperationInfo> context)
        {
            IAsyncResult asyncResult;

            try
            {
                asyncResult = this.blob.BeginSynchronousCopyBlob(sourceAccount, ((BaseBlobObject)sourceBlob).blob, StorageStampHelpers.AdjustNullableDatetimeRange(expiryTime), applicationMetadata, overwriteOption, Helpers.Convert(sourceCondition), Helpers.Convert(destinationCondition), copySource, context.GetResumeCallback(), context.GetResumeState("IBlobObject.BeginSynchronousCopyBlob"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            CopyBlobOperationInfo copyBlobOperationInfo = null;

            try
            {
                copyBlobOperationInfo = this.blob.EndSynchronousCopyBlob(asyncResult);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
            context.ResultData = copyBlobOperationInfo;
        }
Example #7
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));
            }
        }
Example #8
0
 public static void CheckAccountName(string accountName, bool isForSummary)
 {
     StorageStampHelpers.CheckAccountName(accountName, isForSummary, true);
 }
Example #9
0
 public static BlobObjectCondition Convert(IBlobObjectCondition condition)
 {
     if (condition == null)
     {
         return(null);
     }
     return(new BlobObjectCondition(condition.IncludeDisabledContainers, condition.IncludeExpiredBlobs, StorageStampHelpers.AdjustNullableDatetimeRange(condition.IfModifiedSinceTime), StorageStampHelpers.AdjustNullableDatetimeRange(condition.IfNotModifiedSinceTime), StorageStampHelpers.AdjustDateTimeRange(condition.IfLastModificationTimeMatch), StorageStampHelpers.AdjustDateTimeRange(condition.IfLastModificationTimeMismatch), condition.UpdateOptions, condition.LeaseId, condition.IsFetchingMetadata, condition.IsIncludingSnapshots, condition.IsIncludingPageBlobs, condition.IsIncludingAppendBlobs, condition.IsIncludingUncommittedBlobs, condition.IsDeletingOnlySnapshots, condition.IsRequiringNoSnapshots, condition.IsSkippingLastModificationTimeUpdate, condition.SequenceNumberOperator, condition.SequenceNumber, condition.RequiredBlobType, condition.IsMultipleConditionalHeaderEnabled, condition.IsCopyOperationOnAppendBlobsAllowed, condition.IsRequiringLeaseIfNotModifiedSince, condition.IsDiskMountStateConditionRequired, condition.ExcludeSoftDeletedBlobs, condition.EnsureBlobIsAlreadySoftDeleted, condition.IsOperationAllowedOnArchivedBlobs, condition.SkipLeaseCheck, condition.InternalArchiveBlobLMT, condition.InternalArchiveBlobGenerationId, condition.InternalArchiveRequestId, condition.IncludeSoftDeletedBlobsOnly));
 }
Example #10
0
 public static void ValidateServiceMetadata(byte[] serviceMetadata)
 {
     StorageStampHelpers.ValidateServiceProperties(serviceMetadata, null, true);
 }
Example #11
0
 public static void ValidatePutBlockArguments(IBlobObject blob, byte[] blockIdentifier, long contentLength, byte[] contentMD5, IBlobObjectCondition condition)
 {
     StorageStampHelpers.ValidatePutBlockArguments(blob, blockIdentifier, contentLength, contentMD5, condition, false);
 }
Example #12
0
 public static void ValidatePutBlobArguments(IBlobObject blob, long contentLength, long?maxBlobSize, byte[] applicationMetadata, byte[] contentMD5, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition)
 {
     StorageStampHelpers.ValidatePutBlobArguments(blob, contentLength, maxBlobSize, applicationMetadata, contentMD5, sequenceNumberUpdate, overwriteOption, condition, false, false);
 }
Example #13
0
 public static void ValidateApplicationMetadata(NameValueCollection metadata)
 {
     StorageStampHelpers.ValidateApplicationMetadata(MetadataEncoding.GetMetadataLengthWithAsciiEncoding(metadata));
 }
Example #14
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);
        }
Example #15
0
        private IEnumerator <IAsyncResult> CreateTableContainerImpl(string tableName, DateTime?expiryTime, byte[] serviceMetadata, byte[] applicationMetadata, AsyncIteratorContext <ITableContainer> context)
        {
            IAsyncResult           asyncResult;
            IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { tableName, expiryTime, serviceMetadata, applicationMetadata, this.Timeout };
            verboseDebug.Log("CreateTableContainerImpl({0},{1},{2},{3},{4})", objArray);
            try
            {
                asyncResult = this.internalAccount.BeginCreateTableContainer(tableName, StorageStampHelpers.AdjustNullableDatetimeRange(expiryTime), serviceMetadata, applicationMetadata, context.GetResumeCallback(), context.GetResumeState("StorageAccount.CreateTableContainerImpl"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            try
            {
                ITableContainer tableContainer = this.internalAccount.EndCreateTableContainer(asyncResult);
                context.ResultData = new TableContainer(tableContainer);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
        }
Example #16
0
 public static void ValidateServiceProperties(NameValueCollection serviceMetadataCollection, string contentType)
 {
     StorageStampHelpers.ValidateServiceProperties(MetadataEncoding.Encode(serviceMetadataCollection), contentType);
 }
Example #17
0
 public static ContainerCondition Convert(IContainerCondition condition)
 {
     if (condition == null)
     {
         return(null);
     }
     return(new ContainerCondition(condition.IncludeDisabledContainers, condition.IncludeExpiredContainers, condition.IncludeSnapshots, StorageStampHelpers.AdjustNullableDatetimeRange(condition.IfModifiedSinceTime), StorageStampHelpers.AdjustNullableDatetimeRange(condition.IfNotModifiedSinceTime), condition.SnapshotTimestamp, condition.IsRequiringNoSnapshots, condition.IsDeletingOnlySnapshots, condition.LeaseId));
 }
Example #18
0
 public static void ValidateServiceProperties(byte[] serviceMetadata, string contentType)
 {
     StorageStampHelpers.ValidateServiceProperties(serviceMetadata, contentType, false);
 }
Example #19
0
		public override string ToString()
		{
			object[] objArray = new object[] { this.includeDisabledContainers, this.includeExpiredBlobs, (this.ifModifiedSinceTime.HasValue ? this.ifModifiedSinceTime.Value.ToString("O") : "<null>"), (this.ifNotModifiedSinceTime.HasValue ? this.ifNotModifiedSinceTime.Value.ToString("O") : "<null>"), (this.leaseId.HasValue ? this.leaseId.Value.ToString("N") : "<null>"), this.isIncludingUncommittedBlobs, this.isFetchingMetadata, this.isIncludingSnapshots, this.isIncludingPageBlobs, this.isIncludingAppendBlobs, this.isDeletingOnlySnapshots, (this.ifLastModificationTimeMatch != null ? StorageStampHelpers.DateTimeArrayToString(this.ifLastModificationTimeMatch) : "<null>"), (this.ifLastModificationTimeMismatch != null ? StorageStampHelpers.DateTimeArrayToString(this.ifLastModificationTimeMismatch) : "<null>"), this.isRequiringNoSnapshots, this.isSkippingLastModificationTimeUpdate, (this.sequenceNumberOperator.HasValue ? this.sequenceNumberOperator.Value.ToString() : "<null>"), (this.sequenceNumber.HasValue ? this.sequenceNumber.Value.ToString() : "<null>"), this.requiredBlobType, this.IsMultipleConditionalHeaderEnabled, this.IsCopyOperationOnAppendBlobsAllowed, (this.IsRequiringLeaseIfNotModifiedSince.HasValue ? this.IsRequiringLeaseIfNotModifiedSince.Value.ToString("O") : "<null>"), this.IsDiskMountStateConditionRequired, this.ExcludeSoftDeletedBlobs, this.EnsureBlobIsAlreadySoftDeleted, this.isOperationAllowedOnArchivedBlobs, this.skipLeaseCheck, (this.internalArchiveBlobLMT.HasValue ? this.internalArchiveBlobLMT.Value.ToString("O") : "<null>"), (!string.IsNullOrEmpty(this.internalArchiveBlobGenerationId) ? this.internalArchiveBlobGenerationId : "<null>"), (this.internalArchiveRequestId.HasValue ? this.internalArchiveRequestId.ToString() : "<null>"), this.IncludeSoftDeletedBlobsOnly };
			return string.Format("[includeDisabledContainers = {0}, includeExpiredBlobs = {1}, ifModifiedSinceTime = {2}, ifNotModifiedSinceTime = {3}, leaseId = {4}, isIncludingUncommittedBlobs = {5}, isFetchingMetadata = {6}, isIncludingSnapshots = {7}, isIncludingPageBlobs = {8} isIncludingAppendBlobs = {9}, isDeletingOnlySnapshots = {10}, ifLastModificationTimeMatch = {11}, ifLastModificationTimeMismatch = {12}, isRequiringNoSnapshots = {13}, isSkippingLastModificationTimeUpdate = {14}, sequenceNumberOperator = {15}, sequenceNumber = {16}, requiredBlobType = {17}, isMultipleConditionalHeaderEnabled = {18}, IsOperationOnAppendBlobsAllowed = {19}, IsRequiringLeaseIfNotModifiedSince = {20}, isDiskMountStateConditionRequired = {21}, ExcludeSoftDeletedBlobs = {22}, EnsureBlobIsAlreadySoftdeleted = {23}, isOperationAllowedOnArchivedBlobs = {24}, skipLeaseCheck = {25}, internalArchiveBlobLMT = {26}, internalArchiveBlobGenerationId = {27}, internalArchvieRequestId = {28}, includeSoftDeletedBlobsOnly = {29}]", objArray);
		}
Example #20
0
 public static void CheckAccountName(string accountName)
 {
     StorageStampHelpers.CheckAccountName(accountName, false);
 }