public static IEnumerable<EndpointReference> EnumerateEPR(this IMessageBuilder messageBuilder, Filter filter, int maxElements, bool optimize)
        {
            IMessageBuilder nextMessageBuilder;
            var response = messageBuilder
                .StartEnumeration(filter, EnumerationMode.EnumerateEPR, optimize, out nextMessageBuilder);

            if (response.Items != null)
            {
                foreach (var item in response.Items)
                {
                    yield return item.EPRValue;
                }
            }
            var context = response.EnumerationContext;
            var endOfSequence = response.EndOfSequence != null;
            while (!endOfSequence)
            {
                var pullResponse = nextMessageBuilder
                    .PullNextBatch(context, maxElements, out nextMessageBuilder);

                foreach (var item in pullResponse.Items)
                {
                    yield return item.EPRValue;
                }
                endOfSequence = pullResponse.EndOfSequence != null;
                context = pullResponse.EnumerationContext;
            }
        }
 public IEnumerable<EndpointReference> EnumerateEPR(string resourceUri, Filter filter, int maxElements, IEnumerable<Selector> selectors)
 {
     return _soapClient
         .BuildMessage()
         .WithResourceUri(resourceUri)
         .WithSelectors(selectors)
         .EnumerateEPR(filter, maxElements, _optimize);
 }
 public int EstimateCount(string resourceUri, Filter filter, IEnumerable<Selector> selectors)
 {
     return _soapClient
         .BuildMessage()
         .WithResourceUri(resourceUri)
         .WithSelectors(selectors)
         .EstimateEnumerationCount(filter);
 }
 private object CreateFilterInstance(Filter filter)
 {
     if (filter == null)
     {
         return null;
     }
     var filterType = _filterMap.GetFilterType(filter.Dialect);
     if (filterType == null)
     {
         throw new NotSupportedDialectFaultException();
     }
     return filter.DeserializeAs(filterType);
 }
        public static string SubscribeUsingPullDelivery(this IMessageBuilder messageBuilder, Filter filter)
        {
            var responseMessage = messageBuilder
                .WithAction(Constants.SubscribeAction)
                .AddBody(new SubscribeRequest
                             {
                                 Delivery = Delivery.Pull(),
                                 Filter = filter
                             })
                .SendAndGetResponse();

            var response = responseMessage.GetPayload<SubscribeResponse>();
            return response.EnumerationContext.Text;
        }
        public static EnumerateResponse StartEnumeration(this IMessageBuilder messageBuilder, Filter filter, EnumerationMode enumerationMode, bool optimize, out IMessageBuilder nextMessageBuilder)
        {
            var responseMessage = messageBuilder
                .WithAction(Constants.EnumerateAction)               
                .AddBody(new EnumerateRequest
                             {
                                 EnumerationMode = enumerationMode,
                                 OptimizeEnumeration = optimize ? new OptimizeEnumeration() : null,
                                 Filter = filter,
                             })
                .SendAndGetResponse(out nextMessageBuilder);

            return responseMessage.GetPayload<EnumerateResponse>();
        }
        public static int EstimateEnumerationCount(this IMessageBuilder messageBuilder, Filter filter)
        {
            var responseMessage = messageBuilder
                .WithAction(Constants.EnumerateAction)
                .AddHeader(new RequestTotalItemsCountEstimateHeader(), true)
                .AddBody(new EnumerateRequest
                             {
                                 EnumerationMode = EnumerationMode.EnumerateEPR,
                                 Filter = filter
                             })
                .SendAndGetResponse();

            var totalCountEstimateHeader = responseMessage.GetHeader<TotalItemsCountEstimateHeader>();
            if (totalCountEstimateHeader == null)
            {
                throw new InvalidOperationException("Total items count header is missing from the response.");
            }
            return totalCountEstimateHeader.Value;
        }
 public IEnumerable<ObjectName> QueryNames(ObjectName name, IExpression<bool> query)
 {
     var queryExpression = query != null
         ? ExpressionGenerator.Generate(query)
         : null;
     var filter = new Filter(Schema.QueryNamesDialect, queryExpression);
     return _enumClient.EnumerateEPR(Schema.DynamicMBeanResourceUri, filter, _enumerationMaxElements,
                                     name.CreateSelectorSet())
        .Select(x => x.ExtractObjectName());
 }
        private IEnumerationRequestHandler GetHandler(Filter filter)
        {
            var dialect = (filter != null && filter.Dialect != null)
               ? filter.Dialect
               : FilterMap.DefaultDialect;

            IEnumerationRequestHandler supportedDialectHandler;
            if (_handlerMap.TryGetValue(dialect, out supportedDialectHandler))
            {
                return supportedDialectHandler;
            }
            throw new NotSupportedDialectFaultException();
        }        
 public IEnumerable<EndpointReference> EnumerateEPR(string resourceUri, Filter filter, int maxElements, params Selector[] selectors)
 {
     return EnumerateEPR(resourceUri, filter, maxElements, (IEnumerable<Selector>)selectors);
 }
 public int EstimateCount(string resourceUri, Filter filter, params Selector[] selectors)
 {
     return EstimateCount(resourceUri, filter, (IEnumerable<Selector>)selectors);
 }