コード例 #1
0
 /// <summary>
 /// Streams the result.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns>CouchViewResultStream&lt;T&gt;.</returns>
 public CouchViewResultStream <T> StreamResult <T>() where T : ICanJson, new()
 {
     try
     {
         return(new CouchViewResultStream <T>(Request().Stream()));
     }
     catch (WebException e)
     {
         throw BigDException.Create("Query failed", e);
     }
 }
コード例 #2
0
 /// <summary>
 /// Gets the result.
 /// </summary>
 /// <returns>CouchGenericViewResult.</returns>
 public BigDGenericViewResult GetResult()
 {
     try
     {
         return(GetResult <BigDGenericViewResult>());
     }
     catch (WebException e)
     {
         throw BigDException.Create("Query failed", e);
     }
 }
コード例 #3
0
        /// <summary>
        /// Gets the result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns>T.</returns>
        public T GetResult <T>() where T : BigDViewResult, new()
        {
            var req = Request();

            if (Result == null)
            {
                Result = new T();
            }
            else
            {
                // Tell the request what we already have
                req.Etag(Result.etag);
                if (checkETagUsingHead)
                {
                    // Make a HEAD request to avoid transfer of data
                    if (req.Head().Send().IsETagValid())
                    {
                        return((T)Result);
                    }
                    // Set back to GET before proceeding below
                    req.Get();
                }
            }

            JObject json;

            try
            {
                json = req.Parse();
            }
            catch (WebException e)
            {
                throw BigDException.Create("Query failed", e);
            }

            if (json != null) // ETag did not match, view has changed
            {
                Result.Result(json);
                Result.etag = req.Etag();
            }
            return((T)Result);
        }