• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Protocol.QueuePermissions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Queue.Protocol.QueuePermissions的典型用法代码示例。如果您正苦于以下问题:C# QueuePermissions类的具体用法?C# QueuePermissions怎么用?C# QueuePermissions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueuePermissions类属于Microsoft.WindowsAzure.Storage.Queue.Protocol命名空间,在下文中一共展示了QueuePermissions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: QueueSetACLCancellation

        public void QueueSetACLCancellation()
        {
            CloudQueue queue = DefaultQueueClient.GetQueueReference(GenerateNewQueueName());

            QueuePermissions permissions = new QueuePermissions();
            permissions.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessQueuePolicy()
            {
                SharedAccessStartTime = DateTimeOffset.Now - TimeSpan.FromHours(1),
                SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1),
                Permissions = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update
            });

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, XStoreSelectors.QueueTraffic().IfHostNameContains(DefaultQueueClient.Credentials.AccountName)) },
                (options, opContext, callback, state) => queue.BeginSetPermissions(permissions, (QueueRequestOptions)options, opContext, callback, state),
                queue.EndSetPermissions);
        }
开发者ID:Juliako,项目名称:azure-sdk-for-net,代码行数:17,代码来源:QueueCancellationUnitTests.cs


示例2: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

            var cloudTableClient = storageAccount.CreateCloudTableClient();
            var table = cloudTableClient.GetTableReference("Photos");
            table.CreateIfNotExists();
            var cloudBlobClient = storageAccount.CreateCloudBlobClient();
            var container = cloudBlobClient.GetContainerReference(CloudConfigurationManager.GetSetting("ContainerName"));
            if (container.CreateIfNotExists())
            {
                container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
            }
            var cloudQueueClient = storageAccount.CreateCloudQueueClient();
            var queue = cloudQueueClient.GetQueueReference("messagequeue");
            queue.CreateIfNotExists();

            TablePermissions tp = new TablePermissions();
            tp.SharedAccessPolicies.Add("readonly", new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.Query, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            tp.SharedAccessPolicies.Add("edit", new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.Query | SharedAccessTablePermissions.Add | SharedAccessTablePermissions.Update, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            tp.SharedAccessPolicies.Add("admin", new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.Query | SharedAccessTablePermissions.Add | SharedAccessTablePermissions.Update | SharedAccessTablePermissions.Delete, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            tp.SharedAccessPolicies.Add("none", new SharedAccessTablePolicy { Permissions = SharedAccessTablePermissions.None, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            table.SetPermissions(tp);

            BlobContainerPermissions bp = new BlobContainerPermissions();
            bp.SharedAccessPolicies.Add("read", new SharedAccessBlobPolicy { Permissions = SharedAccessBlobPermissions.Read, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(60) });
            container.SetPermissions(bp);

            QueuePermissions qp = new QueuePermissions();
            qp.SharedAccessPolicies.Add("add", new SharedAccessQueuePolicy { Permissions = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.Read, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            qp.SharedAccessPolicies.Add("process", new SharedAccessQueuePolicy { Permissions = SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read, SharedAccessExpiryTime = System.DateTime.UtcNow.AddMinutes(15) });
            queue.SetPermissions(qp);
            queue.Metadata.Add("Resize", "true");
            queue.SetMetadata();
        }
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:40,代码来源:Global.asax.cs


示例3: SetPermissionsAsync

 public virtual Task SetPermissionsAsync(QueuePermissions permissions)
 {
     return this.SetPermissionsAsync(permissions, CancellationToken.None);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudQueue.cs


示例4: SetPermissionsImpl

        /// <summary>
        /// Implementation for the SetPermissions method.
        /// </summary>
        /// <param name="acl">The permissions to set.</param>
        /// <param name="options">A <see cref="QueueRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand"/> that sets the permissions.</returns>
        private RESTCommand<NullType> SetPermissionsImpl(QueuePermissions acl, QueueRequestOptions options)
        {
            MemoryStream memoryStream = new MemoryStream();
            QueueRequest.WriteSharedAccessIdentifiers(acl.SharedAccessPolicies, memoryStream);

            RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.Uri);

            options.ApplyToStorageCommand(putCmd);
            putCmd.Handler = this.ServiceClient.AuthenticationHandler;
            putCmd.BuildClient = HttpClientFactory.BuildHttpClient;
            putCmd.BuildRequest = (cmd, cnt, ctx) => QueueHttpRequestMessageFactory.SetAcl(cmd.Uri, cmd.ServerTimeoutInSeconds, cnt, ctx);
            putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null, cmd, ctx);
            putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
            {
                HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex, ctx);
                GetMessageCountAndMetadataFromResponse(resp);
                return NullType.Value;
            };

            return putCmd;
        }
开发者ID:Juliako,项目名称:azure-sdk-for-net,代码行数:27,代码来源:CloudQueue.cs


示例5: SetPermissionsAsync

 /// <summary>
 /// Sets permissions for the queue.
 /// </summary>
 /// <param name="permissions">The permissions to apply to the queue.</param>
 /// <returns>An <see cref="IAsyncAction"/> that represents an asynchronous action.</returns>
 public IAsyncAction SetPermissionsAsync(QueuePermissions permissions)
 {
     return this.SetPermissionsAsync(permissions, null, null);
 }
开发者ID:Juliako,项目名称:azure-sdk-for-net,代码行数:9,代码来源:CloudQueue.cs


示例6: QueueSASTestAsync

        public async Task QueueSASTestAsync()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue queue = client.GetQueueReference(GenerateNewQueueName());
            await queue.CreateAsync();
            string messageContent = Guid.NewGuid().ToString();
            CloudQueueMessage message = new CloudQueueMessage(messageContent);
            await queue.AddMessageAsync(message);

            // Prepare SAS authentication with full permissions
            string id = Guid.NewGuid().ToString();
            DateTime start = DateTime.UtcNow;
            DateTime expiry = start.AddMinutes(30);
            QueuePermissions permissions = new QueuePermissions();
            SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update;
            permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy()
            {
                SharedAccessStartTime = start,
                SharedAccessExpiryTime = expiry,
                Permissions = queuePerm
            });

            await queue.SetPermissionsAsync(permissions);
            await Task.Delay(30 * 1000);

            string sasTokenFromId = queue.GetSharedAccessSignature(null, id);
            StorageCredentials sasCredsFromId = new StorageCredentials(sasTokenFromId);

            CloudStorageAccount sasAcc = new CloudStorageAccount(sasCredsFromId, null /* blobEndpoint */, new Uri(TestBase.TargetTenantConfig.QueueServiceEndpoint), null /* tableEndpoint */, null /* fileEndpoint */);
            CloudQueueClient sasClient = sasAcc.CreateCloudQueueClient();

            CloudQueue sasQueueFromSasUri = new CloudQueue(sasClient.Credentials.TransformUri(queue.Uri));
            CloudQueueMessage receivedMessage = await sasQueueFromSasUri.PeekMessageAsync();
            Assert.AreEqual(messageContent, receivedMessage.AsString);

            CloudQueue sasQueueFromSasUri1 = new CloudQueue(new Uri(queue.Uri.ToString() + sasTokenFromId));
            CloudQueueMessage receivedMessage1 = await sasQueueFromSasUri1.PeekMessageAsync();
            Assert.AreEqual(messageContent, receivedMessage1.AsString);

            CloudQueue sasQueueFromId = new CloudQueue(queue.Uri, sasCredsFromId);
            CloudQueueMessage receivedMessage2 = await sasQueueFromId.PeekMessageAsync();
            Assert.AreEqual(messageContent, receivedMessage2.AsString);

            string sasTokenFromPolicy = queue.GetSharedAccessSignature(permissions.SharedAccessPolicies[id], null);
            StorageCredentials sasCredsFromPolicy = new StorageCredentials(sasTokenFromPolicy);
            CloudQueue sasQueueFromPolicy = new CloudQueue(queue.Uri, sasCredsFromPolicy);
            CloudQueueMessage receivedMessage3 = await sasQueueFromPolicy.PeekMessageAsync();
            Assert.AreEqual(messageContent, receivedMessage3.AsString);
            await queue.DeleteAsync();
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:50,代码来源:CloudQueueTest.cs


示例7: BeginSetPermissions

        /// <summary>
        /// Begins an asynchronous request to set permissions for the queue.
        /// </summary>
        /// <param name="permissions">The permissions to apply to the queue.</param>
        /// <param name="options">An <see cref="QueueRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.</param>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="ICancellableAsyncResult"/> that references the asynchronous operation.</returns>
        public ICancellableAsyncResult BeginSetPermissions(QueuePermissions permissions, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
        {
            QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient);
            operationContext = operationContext ?? new OperationContext();

            return Executor.BeginExecuteAsync(
                this.SetPermissionsImpl(permissions, modifiedOptions),
                modifiedOptions.RetryPolicy,
                operationContext,
                callback,
                state);
        }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:21,代码来源:CloudQueue.cs


示例8: SetPermissions

        /// <summary>
        /// Sets permissions for the queue.
        /// </summary>
        /// <param name="permissions">The permissions to apply to the queue.</param>
        /// <param name="options">An <see cref="QueueRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.</param>
        public void SetPermissions(QueuePermissions permissions, QueueRequestOptions options = null, OperationContext operationContext = null)
        {
            QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this.ServiceClient);
            operationContext = operationContext ?? new OperationContext();

            Executor.ExecuteSync(
                this.SetPermissionsImpl(permissions, modifiedOptions),
                modifiedOptions.RetryPolicy,
                operationContext);
        }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:16,代码来源:CloudQueue.cs


示例9: SetPermissionsImpl

        /// <summary>
        /// Implementation for the SetPermissions method.
        /// </summary>
        /// <param name="acl">The permissions to set.</param>
        /// <param name="options">An <see cref="QueueRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand{T}"/> that sets the permissions.</returns>
        private RESTCommand<NullType> SetPermissionsImpl(QueuePermissions acl, QueueRequestOptions options)
        {
            MemoryStream memoryStream = new MemoryStream();
            QueueRequest.WriteSharedAccessIdentifiers(acl.SharedAccessPolicies, memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.Uri);

            options.ApplyToStorageCommand(putCmd);
            putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => QueueHttpWebRequestFactory.SetAcl(uri, serverTimeout, ctx);
            putCmd.SendStream = memoryStream;
            putCmd.RecoveryAction = RecoveryActions.RewindStream;
            putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
            putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
            {
                HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex, ctx);
                return NullType.Value;
            };

            return putCmd;
        }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:27,代码来源:CloudQueue.cs


示例10: CloudQueueGetSetPermissionsAPM

        public void CloudQueueGetSetPermissionsAPM()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue queue = client.GetQueueReference(GenerateNewQueueName());

            try
            {
                queue.Create();

                using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                {
                    IAsyncResult result = queue.BeginGetPermissions(ar => waitHandle.Set(), null);
                    waitHandle.WaitOne();
                    QueuePermissions emptyPermission = queue.EndGetPermissions(result);

                    Assert.AreEqual(emptyPermission.SharedAccessPolicies.Count, 0);

                    string id = Guid.NewGuid().ToString();
                    DateTime start = DateTime.UtcNow;
                    DateTime expiry = start.AddMinutes(30);
                    QueuePermissions permissions = new QueuePermissions();
                    SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update;
                    permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy()
                    {
                        SharedAccessStartTime = start,
                        SharedAccessExpiryTime = expiry,
                        Permissions = queuePerm
                    });

                    result = queue.BeginSetPermissions(permissions, ar => waitHandle.Set(), null);
                    waitHandle.WaitOne();
                    queue.EndSetPermissions(result);

                    Thread.Sleep(30 * 1000);

                    CloudQueue queueToRetrieve = client.GetQueueReference(queue.Name);

                    result = queueToRetrieve.BeginGetPermissions(ar => waitHandle.Set(), null);
                    waitHandle.WaitOne();
                    QueuePermissions permissionsToRetrieve = queueToRetrieve.EndGetPermissions(result);

                    AssertPermissionsEqual(permissions, permissionsToRetrieve);
                }
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
开发者ID:jianghaolu,项目名称:azure-storage-net,代码行数:49,代码来源:CloudQueueTest.cs


示例11: AssertPermissionsEqual

        internal static void AssertPermissionsEqual(QueuePermissions permissions1, QueuePermissions permissions2)
        {
            Assert.AreEqual(permissions1.SharedAccessPolicies.Count, permissions2.SharedAccessPolicies.Count);

            foreach (KeyValuePair<string, SharedAccessQueuePolicy> pair in permissions1.SharedAccessPolicies)
            {
                SharedAccessQueuePolicy policy1 = pair.Value;
                SharedAccessQueuePolicy policy2 = permissions2.SharedAccessPolicies[pair.Key];

                Assert.IsNotNull(policy1);
                Assert.IsNotNull(policy2);

                Assert.AreEqual(policy1.Permissions, policy2.Permissions);
                if (policy1.SharedAccessStartTime != null)
                {
                    Assert.IsTrue(Math.Floor((policy1.SharedAccessStartTime.Value - policy2.SharedAccessStartTime.Value).TotalSeconds) == 0);
                }

                if (policy1.SharedAccessExpiryTime != null)
                {
                    Assert.IsTrue(Math.Floor((policy1.SharedAccessExpiryTime.Value - policy2.SharedAccessExpiryTime.Value).TotalSeconds) == 0);
                }
            }
        }
开发者ID:jianghaolu,项目名称:azure-storage-net,代码行数:24,代码来源:CloudQueueTest.cs


示例12: SetPermissionsAsync

 public Task SetPermissionsAsync(QueuePermissions permissions)
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:1,代码来源:CloudQueue.cs


示例13: ReadSharedAccessIdentifiers

        /// <summary>
        /// Reads the share access policies from a stream in XML.
        /// </summary>
        /// <param name="inputStream">The stream of XML policies.</param>
        /// <param name="permissions">The permissions object to which the policies are to be written.</param>
        public static void ReadSharedAccessIdentifiers(Stream inputStream, QueuePermissions permissions)
        {
            CommonUtility.AssertNotNull("permissions", permissions);

            Response.ReadSharedAccessIdentifiers(permissions.SharedAccessPolicies, new QueueAccessPolicyResponse(inputStream));
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:11,代码来源:QueueHttpResponseParsers.Common.cs


示例14: CloudQueueGetSetPermissions

        public void CloudQueueGetSetPermissions()
        {
            CloudQueue queue = DefaultQueueClient.GetQueueReference(GenerateNewQueueName());
           
            try
            {
                queue.Create();
                QueuePermissions emptyPermission = queue.GetPermissions();
                Assert.AreEqual(emptyPermission.SharedAccessPolicies.Count, 0);
                string id = Guid.NewGuid().ToString();
                DateTime start = DateTime.UtcNow;
                DateTime expiry = start.AddMinutes(30);
                QueuePermissions permissions = new QueuePermissions();
                SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add|SharedAccessQueuePermissions.ProcessMessages|SharedAccessQueuePermissions.Read|SharedAccessQueuePermissions.Update;
                permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy()
                {
                    SharedAccessStartTime = start,
                    SharedAccessExpiryTime = expiry,
                    Permissions = queuePerm
                });

                queue.SetPermissions(permissions);
                Thread.Sleep(30 * 1000);

                CloudQueue queueToRetrieve = DefaultQueueClient.GetQueueReference(queue.Name);
                QueuePermissions permissionsToRetrieve = queueToRetrieve.GetPermissions();

                Assert.AreEqual(permissions.SharedAccessPolicies.Count, permissionsToRetrieve.SharedAccessPolicies.Count);
                //Assert.AreEqual(start, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessStartTime.Value.UtcDateTime);
                //Assert.AreEqual(expiry, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessExpiryTime.Value.UtcDateTime);
                Assert.AreEqual(permissions.SharedAccessPolicies[id].Permissions, permissionsToRetrieve.SharedAccessPolicies[id].Permissions);
                
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
开发者ID:thaiphuongs,项目名称:azure-sdk-for-net,代码行数:38,代码来源:CloudQueueTest.cs


示例15: QueueSASTest

        public void QueueSASTest()
        {
            CloudQueue queue = DefaultQueueClient.GetQueueReference(GenerateNewQueueName());

            try
            {
                queue.Create();
                string messageContent = Guid.NewGuid().ToString();
                CloudQueueMessage message = new CloudQueueMessage(messageContent);
                queue.AddMessage(message);

                // Prepare SAS authentication with full permissions
                string id = Guid.NewGuid().ToString();
                DateTime start = DateTime.UtcNow;
                DateTime expiry = start.AddMinutes(30);
                QueuePermissions permissions = new QueuePermissions();
                SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update;
                permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy()
                {
                    SharedAccessStartTime = start,
                    SharedAccessExpiryTime = expiry,
                    Permissions = queuePerm
                });

                queue.SetPermissions(permissions);
                Thread.Sleep(30 * 1000);

                string sasTokenFromId = queue.GetSharedAccessSignature(null, id);
                StorageCredentials sasCredsFromId = new StorageCredentials(sasTokenFromId);
                CloudQueue sasQueueFromId = new CloudQueue(queue.Uri, sasCredsFromId);
                CloudQueueMessage receivedMessage1 = sasQueueFromId.PeekMessage();
                Assert.AreEqual(messageContent, receivedMessage1.AsString);

                string sasTokenFromPolicy = queue.GetSharedAccessSignature(permissions.SharedAccessPolicies[id], null);
                StorageCredentials sasCredsFromPolicy = new StorageCredentials(sasTokenFromPolicy);
                CloudQueue sasQueueFromPolicy = new CloudQueue(queue.Uri, sasCredsFromPolicy);
                CloudQueueMessage receivedMessage2 = sasQueueFromPolicy.PeekMessage();
                Assert.AreEqual(messageContent, receivedMessage2.AsString);
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
开发者ID:thaiphuongs,项目名称:azure-sdk-for-net,代码行数:44,代码来源:CloudQueueTest.cs


示例16: SetPermissionsImpl

        /// <summary>
        /// Implementation for the SetPermissions method.
        /// </summary>
        /// <param name="acl">The permissions to set.</param>
        /// <param name="options">A <see cref="QueueRequestOptions"/> object that specifies additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand"/> that sets the permissions.</returns>
        private RESTCommand<NullType> SetPermissionsImpl(QueuePermissions acl, QueueRequestOptions options)
        {
            MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(null /* bufferManager */, (int)(1 * Constants.KB));
            QueueRequest.WriteSharedAccessIdentifiers(acl.SharedAccessPolicies, memoryStream);

            RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.StorageUri);

            options.ApplyToStorageCommand(putCmd);
            putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.SetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
            putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx);
            putCmd.StreamToDispose = memoryStream;
            putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
            {
                HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex);
                GetMessageCountAndMetadataFromResponse(resp);
                return NullType.Value;
            };

            return putCmd;
        }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:26,代码来源:CloudQueue.cs


示例17: GetPermissionsImpl

        /// <summary>
        /// Implementation for the GetPermissions method.
        /// </summary>
        /// <param name="options">An <see cref="QueueRequestOptions"/> object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand{T}"/> that gets the permissions.</returns>
        private RESTCommand<QueuePermissions> GetPermissionsImpl(QueueRequestOptions options)
        {
            RESTCommand<QueuePermissions> getCmd = new RESTCommand<QueuePermissions>(this.ServiceClient.Credentials, this.Uri);

            options.ApplyToStorageCommand(getCmd);
            getCmd.RetrieveResponseStream = true;
            getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => QueueHttpWebRequestFactory.GetAcl(uri, serverTimeout, ctx);
            getCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
            getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex, ctx);
            getCmd.PostProcessResponse = (cmd, resp, ex, ctx) =>
            {
                QueuePermissions queueAcl = new QueuePermissions();
                QueueHttpResponseParsers.ReadSharedAccessIdentifiers(cmd.ResponseStream, queueAcl);
                return queueAcl;
            };

            return getCmd;
        }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:23,代码来源:CloudQueue.cs


示例18: GetPermissionsImpl

        /// <summary>
        /// Implementation for the GetPermissions method.
        /// </summary>
        /// <param name="options">A <see cref="QueueRequestOptions"/> object that specifies additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand"/> that gets the permissions.</returns>
        private RESTCommand<QueuePermissions> GetPermissionsImpl(QueueRequestOptions options)
        {
            RESTCommand<QueuePermissions> getCmd = new RESTCommand<QueuePermissions>(this.ServiceClient.Credentials, this.StorageUri);

            options.ApplyToStorageCommand(getCmd);
            getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary;
            getCmd.RetrieveResponseStream = true;
            getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.GetAcl(uri, serverTimeout, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
            getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex);
            getCmd.PostProcessResponse = (cmd, resp, ctx) =>
            {
                this.GetMessageCountAndMetadataFromResponse(resp);
                return Task<QueuePermissions>.Factory.StartNew(() =>
                {
                    QueuePermissions queueAcl = new QueuePermissions();
                    QueueHttpResponseParsers.ReadSharedAccessIdentifiers(cmd.ResponseStream, queueAcl);
                    return queueAcl;
                });
            };

            return getCmd;
        }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:27,代码来源:CloudQueue.cs


示例19: SetPermissionsAsync

 public virtual Task SetPermissionsAsync(QueuePermissions permissions)
 {
     return this.SetPermissionsAsync(permissions, null /* options */, null /* operationContext */);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudQueue.cs


示例20: CloudQueueGetSetPermissionsAsync

        public async Task CloudQueueGetSetPermissionsAsync()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue queue = client.GetQueueReference(GenerateNewQueueName());

            await queue.CreateAsync();
            QueuePermissions emptyPermission = await queue.GetPermissionsAsync();
            Assert.AreEqual(emptyPermission.SharedAccessPolicies.Count, 0);
            string id = Guid.NewGuid().ToString();
            DateTime start = DateTime.UtcNow;
            DateTime expiry = start.AddMinutes(30);
            QueuePermissions permissions = new QueuePermissions();
            SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update;
            permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy()
            {
                SharedAccessStartTime = start,
                SharedAccessExpiryTime = expiry,
                Permissions = queuePerm
            });

            await queue.SetPermissionsAsync(permissions);
            await Task.Delay(30 * 1000);

            await queue.FetchAttributesAsync();

            CloudQueue queueToRetrieve = client.GetQueueReference(queue.Name);
            QueuePermissions permissionsToRetrieve = await queueToRetrieve.GetPermissionsAsync();

            Assert.AreEqual(permissions.SharedAccessPolicies.Count, permissionsToRetrieve.SharedAccessPolicies.Count);
            //Assert.AreEqual(start, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessStartTime.Value.UtcDateTime);
            //Assert.AreEqual(expiry, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessExpiryTime.Value.UtcDateTime);
            Assert.AreEqual(permissions.SharedAccessPolicies[id].Permissions, permissionsToRetrieve.SharedAccessPolicies[id].Permissions);

            await queue.DeleteAsync();
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:35,代码来源:CloudQueueTest.cs



注:本文中的Microsoft.WindowsAzure.Storage.Queue.Protocol.QueuePermissions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Protocol.ServiceProperties类代码示例发布时间:2022-05-26
下一篇:
C# Queue.QueueRequestOptions类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap