コード例 #1
0
      public PullResponse Pull(PullRequest request)
      {                  
         //TODO: Check URI
         PullSubscription subsciption;
			if (request.EnumerationContext == null || !_subscriptions.TryGetValue(request.EnumerationContext.Text, out subsciption))
         {
            throw Faults.InvalidEnumerationContext.Create();
         }

         EnumerationModeExtension.Activate(EnumerationMode.EnumerateObjectAndEPR, subsciption.EventType);

         int maxElements = request.MaxElements != null
                              ? request.MaxElements.Value
                              : 1;

         TimeSpan maxTime = request.MaxTime != null 
            ? request.MaxTime.Value 
            : TimeSpan.FromSeconds(10);

         EnumerationItemList items = new EnumerationItemList(PullItems(subsciption.Buffer.FetchNotifications(maxElements, maxTime)));

         //R7.2.13-5
         if (items.Items.Count() == 0)
         {
            throw Faults.TimedOut.Create();
         }
         return new PullResponse
                   {
                      Items = items,
                      EndOfSequence = null,
                      EnumerationContext = request.EnumerationContext
                   };
      }
コード例 #2
0
ファイル: EnumerationServer.cs プロジェクト: nickchal/pash
      public PullResponse Pull(PullRequest request)
      {
         EnumerationState holder;
         if (!_activeEnumerations.TryGetValue(request.EnumerationContext, out holder))
         {
            throw Faults.InvalidEnumerationContext.Create();            
         }
         
         int maxElements = request.MaxElements != null
                              ? request.MaxElements.Value
                              : 1;

         bool endOfSequence;
         EnumerationItemList items = new EnumerationItemList(PullItems(maxElements, holder.Mode, holder.Enumerator, out endOfSequence));
         if (endOfSequence)
         {
            _activeEnumerations.Remove(request.EnumerationContext);
         }
         return new PullResponse
                   {
                      Items = items,
                      EndOfSequence = endOfSequence ? new EndOfSequence() : null,
                      EnumerationContext = endOfSequence ? null : request.EnumerationContext
                   };
      }
コード例 #3
0
        public PullResponse Pull(PullRequest request)
        {
            EnumerationState holder;

            if (!_activeEnumerations.TryGetValue(request.EnumerationContext, out holder))
            {
                throw Faults.InvalidEnumerationContext.Create();
            }

            int maxElements = request.MaxElements != null
                              ? request.MaxElements.Value
                              : 1;

            bool endOfSequence;
            EnumerationItemList items = new EnumerationItemList(PullItems(maxElements, holder.Mode, holder.Enumerator, out endOfSequence));

            if (endOfSequence)
            {
                _activeEnumerations.Remove(request.EnumerationContext);
            }
            return(new PullResponse
            {
                Items = items,
                EndOfSequence = endOfSequence ? new EndOfSequence() : null,
                EnumerationContext = endOfSequence ? null : request.EnumerationContext
            });
        }
コード例 #4
0
ファイル: EnumerationServer.cs プロジェクト: nickchal/pash
      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();
      }
コード例 #5
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();
        }