Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        internal static Message GenerateReleaseMessage(EnumerationContextType context)
        {
            Release op = new Release();

            op.EnumerationContext = context;

            return(Message.CreateMessage(MessageVersion.Soap12WSAddressing10, Namespaces.Release, new SerializerBodyWriter(op)));
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 6
0
        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();
                }
            }
        }
Ejemplo n.º 7
0
        /// <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));
        }