コード例 #1
0
        protected IEnumerator <IAsyncResult> SetTableAclImpl(IAccountIdentifier identifier, string account, string tableName, ContainerAclSettings acl, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            byte[]   numArray;
            Duration startingNow = Duration.StartingNow;

            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }
            if (string.IsNullOrEmpty(account))
            {
                throw new ArgumentException("account", "Cannot be null or empty");
            }
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentException("tableName", "Cannot be null or empty");
            }
            if (acl == null)
            {
                throw new ArgumentNullException("acl");
            }
            if (acl.SASIdentifiers == null)
            {
                throw new ArgumentNullException("sasidentifiers");
            }
            if (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in SetTableAcl");
            }
            RemainingTime remainingTime = new RemainingTime(timeout);

            if (identifier is TableSignedAccessAccountIdentifier || identifier is AccountSasAccessIdentifier)
            {
                throw new NephosUnauthorizedAccessException("Signed access not supported for this request", AuthorizationFailureReason.InvalidOperationSAS);
            }
            IAsyncResult asyncResult = this.authorizationManager.BeginCheckAccess(identifier, account, tableName, null, PermissionLevel.WriteAcl, remainingTime, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableAclImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            using (IStorageAccount storageAccount = this.storageManager.CreateAccountInstance(account))
            {
                using (ITableContainer tableContainer = storageAccount.CreateTableContainerInstance(tableName))
                {
                    acl.EncodeToServiceMetadata(out numArray);
                    ContainerCondition containerCondition = null;
                    tableContainer.ServiceMetadata = numArray;
                    tableContainer.Timeout         = startingNow.Remaining(timeout);
                    asyncResult = tableContainer.BeginSetProperties(ContainerPropertyNames.ServiceMetadata, containerCondition, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableAclImpl"));
                    yield return(asyncResult);

                    tableContainer.EndSetProperties(asyncResult);
                }
            }
        }