Exemplo n.º 1
0
        public async static Task <R.Responses_Query <TResponse> > AsQueryResult <TResponse>(this ICallback callback, Q.Queries_Query <TResponse> query = null) where TResponse : class
        {
            var response = await callback.IsQuery <TResponse>();

            return(new R.Responses_Query <TResponse>
            {
                Payload = response.Payload.ConvertTo <TResponse>(),
                Etag = response.ETag,
                SubscriptionId = query?.SubscriptionId,
                SubscriptionTime = query?.SubscriptionTime,
            });
        }
Exemplo n.º 2
0
        public static void SubscribeWith <TResponse>(this ISubscriptionManager manager, R.Responses_Query <TResponse> dto, Q.Queries_Query <TResponse> query, String Session)
        {
            var key = query.GetCacheKey();

            manager.Manage(dto.Payload, key, query.SubscriptionId, query.SubscriptionType ?? ChangeType.ALL, TimeSpan.FromSeconds(query.SubscriptionTime ?? 3600), Session);
        }
Exemplo n.º 3
0
 public static R.Responses_Query <TResponse> AsSyncQueryResult <TResponse>(this ICallback callback, Q.Queries_Query <TResponse> query = null) where TResponse : class
 {
     return(Task.Run(async() =>
     {
         return await callback.AsQueryResult <TResponse>();
     }).Result);
 }
Exemplo n.º 4
0
        public static R.Responses_Query <TResponse> ToOptimizedCachedAndSubscribedResult <TResponse>(this IRequest request, Q.Queries_Query <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <R.Responses_Query <TResponse> > factory)
        {
            var result = request.ToOptimizedCachedResult(query, cache, () =>
            {
                var response = factory();
                return(response);
            });

            manager.SubscribeWith(result, query, request.GetSessionId());
            return(result);
        }
Exemplo n.º 5
0
        public static async Task <R.Responses_Query <TResponse> > ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Query <TResponse> query, ICacheClient cache, Func <Task <R.Responses_Query <TResponse> > > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.Get <R.Responses_Query <TResponse> >(key);

            if (cached == null)
            {
                cached = await factory();

                cache.Add(key, cached);
            }

            return(cached);
        }
Exemplo n.º 6
0
        public static R.Responses_Query <TResponse> ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Query <TResponse> query, ICacheClient cache, Func <R.Responses_Query <TResponse> > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.GetOrCreate(key, () =>
            {
                return(factory());
            });

            return(cached);
        }
Exemplo n.º 7
0
        public static async Task <R.Responses_Query <TResponse> > ToOptimizedCachedAndSubscribedResult <TResponse>(this IRequest request, Q.Queries_Query <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <Task <R.Responses_Query <TResponse> > > factory)
        {
            var key    = query.GetCacheKey();
            var cached = cache.Get <R.Responses_Query <TResponse> >(key);

            if (cached == null)
            {
                cached = await factory();

                cache.Add(key, cached);
            }
            manager.SubscribeWith(cached, query, request.GetSessionId());

            return(cached);
        }