Ejemplo n.º 1
0
      public int EstimateCount(Uri resourceUri, Filter filter, IEnumerable<Selector> selectors)
      {         
         using (ClientContext<IWSEnumerationContract> ctx =
            new ClientContext<IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
               mx =>
               {                  
                  mx.Add(new ResourceUriHeader(resourceUri.ToString()));
                  mx.Add(new SelectorSetHeader(selectors));
               }))
         {
            OperationContextProxy.Current.AddHeader(new RequestTotalItemsCountEstimate());
            FilterMapExtension.Activate(_filterMap);
            EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
			
            ctx.Channel.Enumerate(new EnumerateRequest
            {
               EnumerationMode = EnumerationMode.EnumerateEPR,
               OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
               Filter = filter,
            });
			
            TotalItemsCountEstimate totalItemsCountEstimate =
               OperationContextProxy.Current.FindHeader<TotalItemsCountEstimate>();               
            return totalItemsCountEstimate.Value;
         }
      }
 public Subsciption Subscribe(Filter filter, 
    IEnumerable<Selector> selectors, 
    Expires expires,
    EndpointAddressBuilder susbcriptionManagerEndpointAddress)
 {         
    PullSubscription subscription = new PullSubscription(Guid.NewGuid().ToString(), _deliveryResourceUri, _eventType, filter, expires, selectors, this);
    _handler.Bind(subscription, susbcriptionManagerEndpointAddress);         
    _deliveryServer.AddSubscription(subscription);         
    _subscriptions[subscription.Identifier] = subscription;
    return subscription;
 }
Ejemplo n.º 3
0
 public IEnumerable<EndpointAddress> EnumerateEPR(Uri resourceUri, Filter filter, int maxElements, IEnumerable<Selector> selectors)
 {
    EnumerateResponse response;
    using (ClientContext<IWSEnumerationContract> ctx = 
       new ClientContext<IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing,  _proxyFactory,
          mx =>
             {
                mx.Add(new ResourceUriHeader(resourceUri.ToString()));
                mx.Add(new SelectorSetHeader(selectors));
             }))
    {
       FilterMapExtension.Activate(_filterMap);
       EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
       response = ctx.Channel.Enumerate(new EnumerateRequest
                                {
                                   EnumerationMode = EnumerationMode.EnumerateEPR,
                                   OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
                                   Filter = filter,
                                   MaxElements = new MaxElements(maxElements)
                                });            
    }
    if (response.Items != null)
    {
       foreach (EnumerationItem item in response.Items.Items)
       {
          yield return item.EprValue;
       }
    }
    EnumerationContextKey context = response.EnumerationContext;
    bool endOfSequence = response.EndOfSequence != null;
    while (!endOfSequence)
    {
       PullResponse pullResponse = PullNextEPRBatch(context, resourceUri.ToString(), maxElements, selectors);            
       foreach (EnumerationItem item in pullResponse.Items.Items)
       {
          yield return item.EprValue;
       }
       endOfSequence = pullResponse.EndOfSequence != null;
       context = pullResponse.EnumerationContext;
    }
 }
Ejemplo n.º 4
0
 public EnumerationContext(string context, Filter filter, IEnumerable<Selector> selectors)
 {
    _context = context;
    _selectors = selectors;
    _filter = filter;
 }
Ejemplo n.º 5
0
 public PullSubscription(string identifier, string deliveryUri, Type eventType, Filter filter, Expires expires, IEnumerable<Selector> selectors, ISubscriptionManager manager) 
    : base(identifier, deliveryUri, eventType, filter, expires, selectors, manager)
 {
 }
Ejemplo n.º 6
0
      private ISubscriptionManager GetManager(string resourceUri, Filter filter)
      {
         string dialect = (filter != null && filter.Dialect != null)
            ? filter.Dialect
            : FilterMap.DefaultDialect;

         //TODO: Fault is no existing
         return _enumHandlers[new HandlerMapKey(resourceUri, dialect)];
      }
Ejemplo n.º 7
0
 private void HandleCountEnumerate(string context, Filter filter)
 {
    int count = GetHandler(filter).EstimateRemainingItemsCount(new EnumerationContext(context, filter, SelectorSetHeader.GetCurrent()));
    OperationContextProxy.Current.AddHeader(new TotalItemsCountEstimate(count));         
 }
Ejemplo n.º 8
0
      private IEnumerationRequestHandler GetHandler(Filter filter)
      {
         //TODO: Add fault if not found
         ResourceUriHeader resourceUriHeader = OperationContextProxy.Current.FindHeader<ResourceUriHeader>();            

         string dialect = (filter != null && filter.Dialect != null) 
            ? filter.Dialect 
            : FilterMap.DefaultDialect;

         return _handlerMap[new HandlerMapKey(resourceUriHeader.ResourceUri, dialect)];
      }
Ejemplo n.º 9
0
 public int EstimateCount(Uri resourceUri, Filter filter, params Selector[] selectors)
 {
    return EstimateCount(resourceUri, filter, (IEnumerable<Selector>) selectors);
 }
Ejemplo n.º 10
0
 public IEnumerable<EndpointAddress> EnumerateEPR(Uri resourceUri, Filter filter, int maxElements, params Selector[] selectors)
 {
    return EnumerateEPR(resourceUri, filter, maxElements, (IEnumerable<Selector>)selectors);
 }