Example #1
0
        private IEnumerator <IAsyncResult> ListQueueContainersImpl(string containerNamePrefix, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxQueueNames, AsyncIteratorContext <IQueueContainerCollection> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { containerNamePrefix, propertyNames, separator, containerNameStart, condition, maxQueueNames, this.Timeout };
            verboseDebug.Log("ListQueueContainersImpl({0},{1},{2},{3},{4},{5},{6})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbQueueContainerCollection>((TimeSpan param0) => {
                DbQueueContainerCollection dbQueueContainerCollections;
                StorageStampHelpers.ValidateMaxContainers(maxQueueNames);
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    IQueryable <Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer> queueContainers = this.MakeListQueueContainersQuery(containerNamePrefix, separator, containerNameStart, condition, maxQueueNames, dbContext);
                    dbQueueContainerCollections = this.ReadListQueueContainersResult(containerNamePrefix, separator, maxQueueNames, queueContainers);
                }
                return(dbQueueContainerCollections);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageStamp.ListQueueContainersImpl"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbQueueContainerCollection>(asyncResult);
        }
Example #2
0
        private IEnumerator <IAsyncResult> CreateContainerImpl(DateTime?expiryTime, byte[] serviceMetadata, byte[] applicationMetadata, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { expiryTime, serviceMetadata, applicationMetadata, this.Timeout };
            verboseDebug.Log("CreateContainerImpl({0},{1},{2},{3})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                StorageStampHelpers.CheckContainerName(this._container.ContainerName, Microsoft.Cis.Services.Nephos.Common.Storage.ContainerType.BlobContainer, false);
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    this._container.ServiceMetadata = serviceMetadata;
                    this._container.Metadata        = applicationMetadata;
                    dbContext.BlobContainers.InsertOnSubmit(this._container);
                    dbContext.SubmitChanges();
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.CreateContainerImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #3
0
        private IEnumerator <IAsyncResult> ListBlobContainersImpl(string containerNamePrefix, ContainerPropertyNames propertyNames, string separator, string containerKeyStart, IContainerCondition condition, int maxContainerNames, AsyncIteratorContext <IBlobContainerCollection> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { containerNamePrefix, propertyNames, separator, containerKeyStart, condition, maxContainerNames, this.Timeout };
            verboseDebug.Log("ListBlobContainersImpl({0},{1},{2},{3},{4},{5},{6})", objArray);
            string str = null;

            if (containerKeyStart != null)
            {
                string[] strArrays = containerKeyStart.Split(new char[] { '/' });
                if ((int)strArrays.Length != 3)
                {
                    throw new ArgumentOutOfRangeException("containerKeyStart", "The marker is not well formed.");
                }
                string str1 = strArrays[1];
                str = strArrays[2];
                if (str1 != this.Name)
                {
                    throw new ArgumentException(string.Format("Account name '{0}' specified in the container key start does not match the account being listed '{1}'", str1, this.Name), "containerKeyStart");
                }
            }
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbBlobContainerCollection>((TimeSpan param0) => {
                DbBlobContainerCollection dbBlobContainerCollections;
                StorageStampHelpers.ValidateMaxContainers(maxContainerNames);
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    IQueryable <Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer> blobContainers = this.MakeListBlobContainersQuery(containerNamePrefix, separator, str, condition, maxContainerNames, dbContext);
                    dbBlobContainerCollections = this.ReadListBlobContainersResult(containerNamePrefix, separator, maxContainerNames, blobContainers);
                }
                return(dbBlobContainerCollections);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageStamp.ListBlobContainersImpl"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbBlobContainerCollection>(asyncResult);
        }
Example #4
0
        private IEnumerator <IAsyncResult> SetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer applicationMetadata = this.LoadQueueContainer(dbContext);
                    if ((propertyNames & ContainerPropertyNames.ApplicationMetadata) != ContainerPropertyNames.None)
                    {
                        StorageStampHelpers.ValidateApplicationMetadata(this.ApplicationMetadata);
                        applicationMetadata.Metadata = this.ApplicationMetadata;
                    }
                    if ((propertyNames & ContainerPropertyNames.ServiceMetadata) != ContainerPropertyNames.None)
                    {
                        applicationMetadata.ServiceMetadata = ((IContainer)this).ServiceMetadata;
                    }
                    dbContext.SubmitChanges();
                    this._queue = applicationMetadata;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.SetProperties"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #5
0
        private IEnumerator <IAsyncResult> SetPropertiesImpl(AccountPropertyNames propertyNames, IAccountCondition conditions, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream infoDebug = Logger <INormalAndDebugLogger> .Instance.InfoDebug;

            object[] objArray = new object[] { propertyNames, conditions, this.Timeout };
            infoDebug.Log("SetPropertiesImpl({0},{1},{2})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    StorageStampHelpers.CheckAccountName(this._account.Name);
                    Account value = this.LoadAccount(dbContext);
                    this._account = value;
                    AnalyticsSettings analyticsSetting      = null;
                    AnalyticsSettings blobAnalyticsSettings = null;
                    AccountServiceMetadataPropertyNames serviceMetadataPropertyNames = propertyNames.ServiceMetadataPropertyNames;
                    if (serviceMetadataPropertyNames <= AccountServiceMetadataPropertyNames.QueueAnalyticsSettings)
                    {
                        if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.BlobAnalyticsSettings)
                        {
                            blobAnalyticsSettings = this.ServiceMetadata.BlobAnalyticsSettings;
                            if (blobAnalyticsSettings != null)
                            {
                                if (value.BlobServiceSettings != null)
                                {
                                    analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.BlobServiceSettings);
                                    this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                                }
                                value.BlobServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                                dbContext.SubmitChanges();
                            }
                        }
                        else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.QueueAnalyticsSettings)
                        {
                            blobAnalyticsSettings = this.ServiceMetadata.QueueAnalyticsSettings;
                            if (blobAnalyticsSettings != null)
                            {
                                if (value.QueueServiceSettings != null)
                                {
                                    analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.QueueServiceSettings);
                                    this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                                }
                                value.QueueServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                                dbContext.SubmitChanges();
                            }
                        }
                    }
                    else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.TableAnalyticsSettings)
                    {
                        blobAnalyticsSettings = this.ServiceMetadata.TableAnalyticsSettings;
                        if (blobAnalyticsSettings != null)
                        {
                            if (value.TableServiceSettings != null)
                            {
                                analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.TableServiceSettings);
                                this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                            }
                            value.TableServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                            dbContext.SubmitChanges();
                        }
                    }
                    else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.SecondaryReadEnabled)
                    {
                        bool?secondaryReadEnabled = this.ServiceMetadata.SecondaryReadEnabled;
                        if (secondaryReadEnabled.HasValue)
                        {
                            value.SecondaryReadEnabled = secondaryReadEnabled.Value;
                            dbContext.SubmitChanges();
                        }
                    }
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.SetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #6
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(AccountPropertyNames propertyNames, IAccountCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { propertyNames, condition, this.Timeout };
            verboseDebug.Log("StorageAccount.GetPropertiesImpl({0},{1},{2})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    StorageStampHelpers.CheckAccountName(this._account.Name);
                    Account account = this.LoadAccount(dbContext);
                    this._account   = account;
                    if (account.SecondaryReadEnabled)
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        this._accountServiceMetadata.SecondaryReadEnabled = new bool?(true);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)32768)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.BlobServiceSettings == null)
                        {
                            this._accountServiceMetadata.BlobAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.BlobAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.BlobServiceSettings);
                        }
                        this._accountServiceMetadata.BlobGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)65536)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.QueueServiceSettings == null)
                        {
                            this._accountServiceMetadata.QueueAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.QueueAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.QueueServiceSettings);
                        }
                        this._accountServiceMetadata.QueueGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)131072)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.TableServiceSettings == null)
                        {
                            this._accountServiceMetadata.TableAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.TableAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.TableServiceSettings);
                        }
                        this._accountServiceMetadata.TableGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.GetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #7
0
        private IEnumerator <IAsyncResult> PutBlockImpl(byte[] blockIdentifier, long contentLength, Stream inputStream, byte[] contentMD5, bool isLargeBlockBlobRequest, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer = null;
            BlockBlob    blockBlob   = null;
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                long num;
                long num1;
                StorageStampHelpers.ValidatePutBlockArguments(this, blockIdentifier, contentLength, contentMD5, condition, true);
                string str = null;
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    blobContainer = base.LoadContainer(dbContext);
                    blockBlob     = base.TryLoadBlockBlob(dbContext, out str);
                    if (blockBlob == null)
                    {
                        lock (DbListBlobObject.SynchronizePutBlock)
                        {
                            blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                            if (blockBlob == null)
                            {
                                if (string.IsNullOrEmpty(str))
                                {
                                    str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                                }
                                using (DevelopmentStorageDbDataContext developmentStorageDbDataContext = DevelopmentStorageDbDataContext.GetDbContext())
                                {
                                    Logger <INormalAndDebugLogger> .Instance.VerboseDebug.Log("PutBlockImpl: Creating record for ({0};{1};{2})", new object[] { this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName });
                                    StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                                    blockBlob = new BlockBlob()
                                    {
                                        AccountName      = this._blob.AccountName,
                                        ContainerName    = this._blob.ContainerName,
                                        BlobName         = this._blob.BlobName,
                                        VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                        ContentLength    = (long)0,
                                        IsCommitted      = new bool?(false),
                                        HasBlock         = new bool?(true),
                                        DirectoryPath    = str,
                                        GenerationId     = Guid.NewGuid().ToString(),
                                        SnapshotCount    = 0
                                    };
                                    developmentStorageDbDataContext.Blobs.InsertOnSubmit(blockBlob);
                                    developmentStorageDbDataContext.SubmitChanges();
                                }
                            }
                        }
                    }
                    bool flag = false;
                    BlobLeaseInfo blobLeaseInfo = new BlobLeaseInfo(blockBlob, DateTime.UtcNow);
                    DbBlobObject.CheckCopyState(blockBlob);
                    flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, blobLeaseInfo, condition, null, true);
                    byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, true, isLargeBlockBlobRequest);
                    string file          = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1);
                    string hexString     = DbListBlobObject.ToHexString(blockIdentifier);
                    BlockData blockDatum = this.TryLoadUncommittedBlock(dbContext, hexString);
                    if (blockDatum == null)
                    {
                        blockDatum = new BlockData()
                        {
                            AccountName      = this._blob.AccountName,
                            ContainerName    = this._blob.ContainerName,
                            BlobName         = this._blob.BlobName,
                            VersionTimestamp = this._blob.VersionTimestamp,
                            IsCommitted      = false,
                            BlockId          = hexString
                        };
                        dbContext.BlocksData.InsertOnSubmit(blockDatum);
                    }
                    blockDatum.Length      = new long?(num);
                    blockDatum.FilePath    = file;
                    blockDatum.StartOffset = new long?(num1);
                    base.ResetBlobLeaseToAvailable(blockBlob, flag);
                    dbContext.SubmitChanges();
                    blobLeaseInfo.SetBlob(blockBlob, blobLeaseInfo.LeaseInfoValidAt);
                    this.LeaseInfo = blobLeaseInfo;
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlock"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #8
0
        private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, byte[][] blockList, BlockSource[] blockSourceList, byte[] contentMD5, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { contentType, this.ContentLength, serviceMetadata, applicationMetadata, blockList, overwriteOption, condition, base.Timeout };
            verboseDebug.Log("PutBlobImpl.PutBlobImpl({0};{1};{2};{3};{4};{5};{6};{7})", objArray);
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        string str          = null;
                        BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                        DateTime utcNow     = DateTime.UtcNow;
                        bool flag           = false;
                        if (blockBlob != null)
                        {
                            DbBlobObject.CheckCopyState(blockBlob);
                            flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true);
                            if (blockBlob.IsCommitted.Value)
                            {
                                if (overwriteOption == OverwriteOption.CreateNewOnly)
                                {
                                    throw new BlobAlreadyExistsException();
                                }
                            }
                            else if (overwriteOption == OverwriteOption.UpdateExistingOnly && condition != null && !condition.IsIncludingUncommittedBlobs)
                            {
                                throw new ConditionNotMetException();
                            }
                        }
                        else
                        {
                            if (overwriteOption == OverwriteOption.UpdateExistingOnly)
                            {
                                if (condition == null || !condition.LeaseId.HasValue)
                                {
                                    throw new ConditionNotMetException();
                                }
                                throw new LeaseNotPresentException();
                            }
                            StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                            if (string.IsNullOrEmpty(str))
                            {
                                str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                            }
                            blockBlob = new BlockBlob()
                            {
                                AccountName      = this._blob.AccountName,
                                ContainerName    = this._blob.ContainerName,
                                BlobName         = this._blob.BlobName,
                                VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                IsCommitted      = new bool?(false),
                                DirectoryPath    = str
                            };
                            dbContext.Blobs.InsertOnSubmit(blockBlob);
                        }
                        StorageStampHelpers.ValidatePutBlockListArguments(this, contentLength, applicationMetadata, blockList, blockSourceList, contentMD5, condition, this._blobServiceVersion);
                        blockBlob.ContentType     = contentType ?? "application/octet-stream";
                        blockBlob.ContentMD5      = contentMD5;
                        blockBlob.ServiceMetadata = serviceMetadata;
                        blockBlob.Metadata        = applicationMetadata;
                        blockBlob.HasBlock        = new bool?(true);
                        blockBlob.GenerationId    = Guid.NewGuid().ToString();
                        blockBlob.SnapshotCount   = 0;
                        base.ResetBlobLeaseToAvailable(blockBlob, flag);
                        dbContext.SubmitChanges();
                        DateTime?nullable           = null;
                        StringBuilder stringBuilder = new StringBuilder();
                        for (int i = 0; i < (int)blockList.Length; i++)
                        {
                            DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, blockList[i], (blockSourceList != null ? blockSourceList[i] : BlockSource.Uncommitted));
                        }
                        dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable);
                        transactionScope.Complete();
                        blockBlob.LastModificationTime = nullable;
                        this._blob     = blockBlob;
                        this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow);
                    }
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlob"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #9
0
        private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, Stream inputStream, byte[] contentMD5, bool invokeGeneratePutBlobServiceMetadata, GeneratePutBlobServiceMetadata generatePutBlobServiceMetadata, bool isLargeBlockBlobRequest, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                long num;
                long num1;
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        string str          = null;
                        BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                        DateTime utcNow     = DateTime.UtcNow;
                        bool flag           = false;
                        if (blockBlob != null)
                        {
                            if (blockBlob.IsCommitted.Value && overwriteOption == OverwriteOption.CreateNewOnly)
                            {
                                throw new BlobAlreadyExistsException();
                            }
                            DbBlobObject.CheckCopyState(blockBlob);
                            flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true);
                            dbContext.ClearUncommittedBlocks(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName);
                            dbContext.Refresh(RefreshMode.KeepChanges, blockBlob);
                        }
                        else
                        {
                            if (overwriteOption == OverwriteOption.UpdateExistingOnly)
                            {
                                if (condition == null || !condition.LeaseId.HasValue)
                                {
                                    throw new ConditionNotMetException();
                                }
                                throw new LeaseNotPresentException();
                            }
                            StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                            if (string.IsNullOrEmpty(str))
                            {
                                str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                            }
                            blockBlob = new BlockBlob()
                            {
                                AccountName      = this._blob.AccountName,
                                ContainerName    = this._blob.ContainerName,
                                BlobName         = this._blob.BlobName,
                                VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                DirectoryPath    = str
                            };
                            dbContext.Blobs.InsertOnSubmit(blockBlob);
                        }
                        StorageStampHelpers.ValidatePutBlobArguments(this, contentLength, null, applicationMetadata, contentMD5, sequenceNumberUpdate, overwriteOption, condition, true, false);
                        byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, false, isLargeBlockBlobRequest);
                        string file          = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1);
                        Guid guid            = Guid.NewGuid();
                        BlockData blockDatum = new BlockData()
                        {
                            AccountName      = this._blob.AccountName,
                            ContainerName    = this._blob.ContainerName,
                            BlobName         = this._blob.BlobName,
                            VersionTimestamp = this._blob.VersionTimestamp,
                            IsCommitted      = false,
                            BlockId          = DbListBlobObject.ToHexString(guid.ToByteArray()),
                            FilePath         = file,
                            StartOffset      = new long?(num1)
                        };
                        dbContext.BlocksData.InsertOnSubmit(blockDatum);
                        if (invokeGeneratePutBlobServiceMetadata && generatePutBlobServiceMetadata != null)
                        {
                            serviceMetadata = generatePutBlobServiceMetadata();
                        }
                        blockBlob.ContentType              = contentType ?? "application/octet-stream";
                        blockBlob.ContentMD5               = contentMD5;
                        blockBlob.ServiceMetadata          = serviceMetadata;
                        blockBlob.Metadata                 = applicationMetadata;
                        blockBlob.IsCommitted              = new bool?(false);
                        blockBlob.HasBlock                 = new bool?(false);
                        blockBlob.UncommittedBlockIdLength = null;
                        blockBlob.GenerationId             = Guid.NewGuid().ToString();
                        blockBlob.SnapshotCount            = 0;
                        blockDatum.Length       = new long?(num);
                        blockBlob.ContentLength = num;
                        base.ResetBlobLeaseToAvailable(blockBlob, flag);
                        dbContext.SubmitChanges();
                        StringBuilder stringBuilder = new StringBuilder();
                        DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, guid.ToByteArray(), BlockSource.Uncommitted);
                        DateTime?nullable = null;
                        dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable);
                        transactionScope.Complete();
                        blockBlob.LastModificationTime = nullable;
                        this._blob     = blockBlob;
                        this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow);
                    }
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlobImpl"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }