Beispiel #1
0
        private IEnumerator <IAsyncResult> SetTableServicePropertiesImpl(IAccountIdentifier identifier, string ownerAccountName, AnalyticsSettings settings, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            Duration startingNow = Duration.StartingNow;

            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }
            if (string.IsNullOrEmpty(ownerAccountName))
            {
                throw new ArgumentException("ownerAccountName", "Cannot be null");
            }
            if (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in SetTableServiceProperties");
            }
            if (identifier is TableSignedAccessAccountIdentifier)
            {
                throw new NephosUnauthorizedAccessException("Signed access not supported for this request", AuthorizationFailureReason.InvalidOperationSAS);
            }
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.AccountSas,
                SignedResourceType = SasResourceType.Service,
                SignedPermission   = SASPermission.Write
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;
            IAsyncResult asyncResult = this.authorizationManager.BeginCheckAccess(identifier, ownerAccountName, null, null, PermissionLevel.Write | PermissionLevel.Owner, sASAuthorizationParameter1, timeout, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableServicePropertiesImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            IStorageAccount  accountServiceMetadatum = null;
            AccountCondition accountCondition        = new AccountCondition(false, false, null, null);

            accountServiceMetadatum = this.storageManager.CreateAccountInstance(ownerAccountName);
            accountServiceMetadatum.ServiceMetadata = new AccountServiceMetadata()
            {
                TableAnalyticsSettings = settings
            };
            accountServiceMetadatum.Timeout = timeout;
            asyncResult = accountServiceMetadatum.BeginSetProperties(new AccountPropertyNames(AccountLevelPropertyNames.None, (AccountServiceMetadataPropertyNames)((long)131072)), accountCondition, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableServicePropertiesImpl"));
            yield return(asyncResult);

            accountServiceMetadatum.EndSetProperties(asyncResult);
        }