Exemple #1
0
      private EnumerateResponse HandleOptimizedEnumerate(EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
      {
         int maxElements = request.MaxElements != null 
                              ? request.MaxElements.Value 
                              : 1;

         if (request.EnumerationMode == EnumerationMode.EnumerateEPR)
         {
            IEnumerator<object> enumerator = GetHandler(request.Filter).Enumerate(context).GetEnumerator();

            bool endOfSequence;
            EnumerationItemList items = new EnumerationItemList(PullItems(maxElements, request.EnumerationMode,enumerator, out endOfSequence));
            if (!endOfSequence)
            {
               _activeEnumerations[contextKey] = new EnumerationState(enumerator, request.EnumerationMode);
            }
            return new EnumerateResponse
                      {
                         Items = items,
                         EndOfSequence = endOfSequence ? new EndOfSequence() : null,
                         EnumerationContext = endOfSequence ? null : contextKey
                      };
         }
         throw new NotSupportedException();
      }
Exemple #2
0
      public EnumerateResponse Enumerate(EnumerateRequest request)
      {         
         EnumerationContextKey contextKey = EnumerationContextKey.Unique();         
         EnumerationContext context = new EnumerationContext(contextKey.Text, request.Filter, SelectorSetHeader.GetCurrent());
         if (RequestTotalItemsCountEstimate.IsPresent)
         {
            HandleCountEnumerate(contextKey.Text, request.Filter);
            return new EnumerateResponse
            {
               EnumerationContext = contextKey
            };
         }
         if (request.OptimizeEnumeration != null)
         {
            return HandleOptimizedEnumerate(contextKey, request, context);
         }         

         IEnumerator<object> enumerator = GetHandler(request.Filter).Enumerate(context).GetEnumerator();
         _activeEnumerations[contextKey] = new EnumerationState(enumerator, request.EnumerationMode);
         return new EnumerateResponse
                   {
                      EnumerationContext = contextKey,
                      Expires = request.Expires
                   };
      }
Exemple #3
0
        public EnumerateResponse Enumerate(EnumerateRequest request)
        {
            EnumerationContextKey contextKey = EnumerationContextKey.Unique();
            EnumerationContext    context    = new EnumerationContext(contextKey.Text, request.Filter, SelectorSetHeader.GetCurrent());

            if (RequestTotalItemsCountEstimate.IsPresent)
            {
                HandleCountEnumerate(contextKey.Text, request.Filter);
                return(new EnumerateResponse
                {
                    EnumerationContext = contextKey
                });
            }
            if (request.OptimizeEnumeration != null)
            {
                return(HandleOptimizedEnumerate(contextKey, request, context));
            }

            IEnumerator <object> enumerator = GetHandler(request.Filter).Enumerate(context).GetEnumerator();

            _activeEnumerations[contextKey] = new EnumerationState(enumerator, request.EnumerationMode);
            return(new EnumerateResponse
            {
                EnumerationContext = contextKey,
                Expires = request.Expires
            });
        }
Exemple #4
0
        private EnumerateResponse HandleOptimizedEnumerate(EnumerationContextKey contextKey, EnumerateRequest request, EnumerationContext context)
        {
            int maxElements = request.MaxElements != null
                              ? request.MaxElements.Value
                              : 1;

            if (request.EnumerationMode == EnumerationMode.EnumerateEPR)
            {
                IEnumerator <object> enumerator = GetHandler(request.Filter).Enumerate(context).GetEnumerator();

                bool endOfSequence;
                EnumerationItemList items = new EnumerationItemList(PullItems(maxElements, request.EnumerationMode, enumerator, out endOfSequence));
                if (!endOfSequence)
                {
                    _activeEnumerations[contextKey] = new EnumerationState(enumerator, request.EnumerationMode);
                }
                return(new EnumerateResponse
                {
                    Items = items,
                    EndOfSequence = endOfSequence ? new EndOfSequence() : null,
                    EnumerationContext = endOfSequence ? null : contextKey
                });
            }
            throw new NotSupportedException();
        }