/// <summary> /// Initializes a new instance of the SearchResultCollection class /// </summary> /// <param name="response">The initial enumeration response from the Resource Management Service</param> /// <param name="pageSize">The page size used in the search operation</param> /// <param name="searchClient">The client proxy used for performing the search</param> /// <param name="client">The client used to convert response data into ResourceObjects</param> /// <param name="locale">The localization culture that the search results are represented as</param> internal SearchResultPager(EnumerateResponse response, int pageSize, SearchClient searchClient, ResourceManagementClient client, CultureInfo locale) { if (response == null) { throw new ArgumentNullException("response"); } if (pageSize < 0) { throw new ArgumentException("The page size must be zero or greater", "pageSize"); } if (searchClient == null) { throw new ArgumentNullException("client"); } this.TotalCount = Convert.ToInt32(response.EnumerationDetail.Count); this.client = client; this.locale = locale; this.context = response.EnumerationContext; this.context.CurrentIndex = 0; this.PageSize = pageSize; this.searchClient = searchClient; this.EndOfSequence = response.EndOfSequence != null; }
internal static Message GenerateReleaseMessage(EnumerationContextType context) { Release op = new Release(); op.EnumerationContext = context; return(Message.CreateMessage(MessageVersion.Soap12WSAddressing10, Namespaces.Release, new SerializerBodyWriter(op))); }
internal static Message GeneratePullMessage(EnumerationContextType context, int pageSize) { Pull op = new Pull(); op.EnumerationContext = context; op.MaxElements = pageSize.ToString(); return(Message.CreateMessage(MessageVersion.Soap12WSAddressing10, Namespaces.Pull, new SerializerBodyWriter(op))); }
internal void Release(EnumerationContextType context) { using (Message releaseRequest = MessageComposer.GenerateReleaseMessage(context)) { using (Message responseMessage = Release(releaseRequest)) { releaseRequest.ThrowOnFault(); } } }
internal PullResponse Pull(EnumerationContextType context, int pageSize) { using (Message pullRequest = MessageComposer.GeneratePullMessage(context, pageSize)) { using (Message responseMessage = this.Invoke((c) => c.Pull(pullRequest))) { responseMessage.ThrowOnFault(); PullResponse pullResponseTyped = responseMessage.DeserializeMessageWithPayload <PullResponse>(); return(pullResponseTyped); } } }
internal void Release(EnumerationContextType context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } using (Message releaseRequest = MessageComposer.GenerateReleaseMessage(context)) { using (Message responseMessage = this.Release(releaseRequest)) { responseMessage.ThrowOnFault(); } } }
/// <summary> /// Gets the next page of search results from the Resource Management Service /// </summary> /// <returns>An enumeration of the ResourceObjects in the page</returns> public IEnumerable <ResourceObject> GetNextPage() { PullResponse r = this.searchClient.Pull(this.context, this.PageSize); if (r.EndOfSequence != null) { this.EndOfSequence = true; } if (r.EnumerationContext != null) { this.context = r.EnumerationContext; } return(this.EnumerateResultSet(r.Items)); }