예제 #1
0
        /// <summary>
        /// Get the single result from the given segment info
        /// </summary>
        /// <param name="segmentInfo">segmentInfo which contains the request query</param>
        /// <returns>query result as returned by the IQueryable query</returns>
        internal static IEnumerator GetSingleResultFromEnumerable(SegmentInfo segmentInfo)
        {
            IEnumerator queryResults  = WebUtil.GetRequestEnumerator(segmentInfo.RequestEnumerable);
            bool        shouldDispose = true;

            try
            {
                WebUtil.CheckResourceExists(queryResults.MoveNext(), segmentInfo.Identifier);

                CheckQueryResult(queryResults.Current, segmentInfo);

                shouldDispose = false;
                return(queryResults);
            }
            finally
            {
                // Dispose the Enumerator in case of error
                if (shouldDispose)
                {
                    WebUtil.Dispose(queryResults);
                }
            }
        }