Пример #1
0
        private OutgoingMessage HandleNormalEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            var responseMessage = CreateEnumerateResponse();
            var enumerator = GetEnumerator(request, requestMessage, context, responseMessage);

            OnEnumerationStarted(context.Context, enumerator, request.EnumerationMode);

            responseMessage.SetBody(
                new SerializerBodyWriter(new EnumerateResponse
                                             {
                                                 EnumerationContext = contextKey,
                                                 Expires = request.Expires
                                             }));
            return responseMessage;
        }
Пример #2
0
 private IEnumerator <object> GetEnumerator(EnumerateRequest request, IncomingMessage requestMessage, EnumerationContext context, OutgoingMessage responseMessage)
 {
     return(GetHandler(request.Filter)
            .Enumerate(context, requestMessage, responseMessage)
            .GetEnumerator());
 }
Пример #3
0
        private OutgoingMessage HandleNormalEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            var responseMessage = CreateEnumerateResponse();
            var enumerator      = GetEnumerator(request, requestMessage, context, responseMessage);

            OnEnumerationStarted(context.Context, enumerator, request.EnumerationMode);

            responseMessage.SetBody(
                new SerializerBodyWriter(new EnumerateResponse
            {
                EnumerationContext = contextKey,
                Expires            = request.Expires
            }));
            return(responseMessage);
        }
Пример #4
0
        private OutgoingMessage HandleOptimizedEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            var responseMessage = CreateEnumerateResponse();
            var maxElements     = CalculateMaxElements(request.MaxElements);

            if (request.EnumerationMode == EnumerationMode.EnumerateEPR)
            {
                var  enumerator = GetEnumerator(request, requestMessage, context, responseMessage);
                bool endOfSequence;
                var  items = enumerator.Take(maxElements, out endOfSequence);
                if (!endOfSequence)
                {
                    OnEnumerationStarted(context.Context, enumerator, request.EnumerationMode);
                }
                responseMessage.SetBody(new SerializerBodyWriter(
                                            new EnumerateResponse
                {
                    Items              = new EnumerationItemList(items, request.EnumerationMode),
                    EndOfSequence      = endOfSequence ? new EndOfSequence() : null,
                    EnumerationContext = endOfSequence ? null : contextKey
                }));
                return(responseMessage);
            }
            throw new NotSupportedException();
        }
Пример #5
0
        private OutgoingMessage HandleCountEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            var responseMessage = CreateEnumerateResponse();
            int count           = GetHandler(request.Filter)
                                  .EstimateRemainingItemsCount(context, requestMessage, responseMessage);

            responseMessage.AddHeader(new TotalItemsCountEstimateHeader(count), false);
            responseMessage.SetBody(new SerializerBodyWriter(new EnumerateResponse
            {
                EnumerationContext = contextKey
            }));
            return(responseMessage);
        }
Пример #6
0
 private IEnumerator<object> GetEnumerator(EnumerateRequest request, IncomingMessage requestMessage, EnumerationContext context, OutgoingMessage responseMessage)
 {
     return GetHandler(request.Filter)
         .Enumerate(context, requestMessage, responseMessage)
         .GetEnumerator();
 }
Пример #7
0
 private OutgoingMessage HandleOptimizedEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
 {
     var responseMessage = CreateEnumerateResponse();
     var maxElements = CalculateMaxElements(request.MaxElements);
     if (request.EnumerationMode == EnumerationMode.EnumerateEPR)
     {
         var enumerator = GetEnumerator(request, requestMessage, context, responseMessage);
         bool endOfSequence;
         var items = enumerator.Take(maxElements, out endOfSequence);
         if (!endOfSequence)
         {
             OnEnumerationStarted(context.Context, enumerator, request.EnumerationMode);
         }
         responseMessage.SetBody(new SerializerBodyWriter(
                              new EnumerateResponse
                                  {
                                      Items = new EnumerationItemList(items, request.EnumerationMode),
                                      EndOfSequence = endOfSequence ? new EndOfSequence() : null,
                                      EnumerationContext = endOfSequence ? null : contextKey
                                  }));
         return responseMessage;
     }
     throw new NotSupportedException();
 }                     
Пример #8
0
        private OutgoingMessage HandleCountEnumerate(IncomingMessage requestMessage, EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            var responseMessage = CreateEnumerateResponse();
            int count = GetHandler(request.Filter)
                .EstimateRemainingItemsCount(context, requestMessage, responseMessage);

            responseMessage.AddHeader(new TotalItemsCountEstimateHeader(count), false);
            responseMessage.SetBody(new SerializerBodyWriter(new EnumerateResponse
                                                          {
                                                              EnumerationContext = contextKey
                                                          }));
            return responseMessage;
        }