Пример #1
0
        protected override IEnumerator <IAsyncResult> GetMessagesImpl(IAccountIdentifier identity, string account, string queue, int numMessages, long?visibilityTimeout, TimeSpan?timeout, RequestContext requestContext, AsyncIteratorContext <IEnumerable <PoppedMessage> > context)
        {
            object obj;

            this.ValidateNumMessages(numMessages, this.config.MaxMessagesToReturn);
            RemainingTime remainingTime = new RemainingTime(timeout);
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.ResourceSas | SasType.AccountSas,
                SignedResourceType = SasResourceType.Object,
                SignedPermission   = SASPermission.Process
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;
            IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.ReadDelete, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.GetMessagesImpl"));

            yield return(asyncResult);

            IQueueContainer operationStatus = this.EndGetQueue(asyncResult);

            if (requestContext != null)
            {
                operationStatus.OperationStatus = requestContext.OperationStatus;
            }
            long?nullable = visibilityTimeout;

            obj = (nullable.HasValue ? nullable.GetValueOrDefault() : this.config.DefaultVisibilityTimeoutSeconds);
            TimeSpan timeSpan = TimeSpan.FromSeconds((double)obj);

            operationStatus.Timeout = remainingTime;
            asyncResult             = operationStatus.BeginGetMessage(numMessages, timeSpan, context.GetResumeCallback(), context.GetResumeState("QueueManager.GetMessagesImpl"));
            yield return(asyncResult);

            IEnumerable <IMessageData> messageDatas = operationStatus.EndGetMessage(asyncResult);
            StringBuilder stringBuilder             = new StringBuilder();

            context.ResultData = this.WrapGetMessageResults(messageDatas);
            int num = 0;

            foreach (PoppedMessage resultDatum in context.ResultData)
            {
                stringBuilder.Append(string.Format("[{0}],", resultDatum.ToString()));
                num++;
            }
            IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            object[] str = new object[] { num, stringBuilder.ToString() };
            verboseDebug.Log("GetMessages response: Count={0} Messages={1}", str);
        }