コード例 #1
0
 public static Object ToOptimizedCachedAndSubscribedResult <TResponse>(this IRequest request, Q.PagedQuery <TResponse> query, ICacheClient cache, ISubscriptionManager manager, IQueryProcessor processor)
 {
     return(request.ToOptimizedCachedAndSubscribedResult(query, cache, manager, () =>
     {
         return processor.Process(query);
     }));
 }
コード例 #2
0
        public static Object ToOptimizedCachedAndSubscribedResult <TResponse>(this IRequest request, Q.PagedQuery <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <R.Query <R.Paged <TResponse> > > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.GetOrCreate(key, () =>
            {
                return(factory());
            });

            // Send response to client, so our subscription stuff doesn't delay the client
            request.Response.ContentType = request.ResponseContentType;
            request.Response.WriteToResponse(request, cached);
            request.Response.EndRequest();

            var documentId = "";
            var idField    = typeof(TResponse).GetProperty("Id", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

            foreach (var each in cached.Payload.Records)
            {
                if (idField != null)
                {
                    documentId = idField.GetValue(each).ToString();
                }

                manager.Manage <TResponse>(key, documentId, query.SubscriptionId, request.GetPermanentSessionId());
            }

            if (!query.SubscriptionId.IsNullOrEmpty())
            {
                manager.Manage <TResponse>(key, "", query.SubscriptionId, request.GetPermanentSessionId());
            }

            return(cached);
        }
コード例 #3
0
 public static R.Query <R.Paged <T> > ToQueryResponse <T>(this R.Paged <T> dto, Q.PagedQuery <T> query) where T : R.IResponse, new()
 {
     return(new R.Query <R.Paged <T> > {
         Payload = dto, Etag = Guid.Empty, SubscriptionId = query.SubscriptionId
     });
 }