Beispiel #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,
            });
        }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }