Example #1
0
 public void Reset(IAsyncDecorator currentFilter)
 {
     decoratorIndex = Array.IndexOf(decorators, currentFilter);
     if (headers != null)
     {
         headers.Clear();
     }
     Timestamp = DateTimeOffset.UtcNow;
 }
Example #2
0
        public virtual async Task <TTransformedResult> ExecuteAsync(TContext context, IAsyncDecorator decorator, IAsyncQueryCache <TCacheEntryOptions> queryCache, CacheOption cacheOption = CacheOption.Default)
        {
            var cachedResult = await GetCachedResultAsync(context, decorator, queryCache, cacheOption).ConfigureAwait(false);

            return(await TransformCachedResultAsync(cachedResult).ConfigureAwait(false));
        }
Example #3
0
 public virtual Task <TResult> ExecuteAsync(TContext context, IAsyncDecorator decorator, IAsyncQueryCache <TCacheEntryOptions> queryCache, CacheOption cacheOption = CacheOption.Default) =>
 GetCachedResultAsync(context, decorator, queryCache, cacheOption);
Example #4
0
        protected virtual async Task <TCachedResult> GetCachedResultAsync(TContext context, IAsyncDecorator decorator, IAsyncQueryCache <TCacheEntryOptions> queryCache, CacheOption cacheOption = CacheOption.Default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (decorator == null)
            {
                throw new ArgumentNullException(nameof(decorator));
            }
            if (queryCache == null)
            {
                throw new ArgumentNullException(nameof(queryCache));
            }

            State.Inject(context);
            Task <TCachedResult> queryAsync() => decorator.Decorate(this, () => QueryAsync(context));

            if (cacheOption == CacheOption.Default)
            {
                return(State.CachedResult = await queryCache.GetAsync(queryAsync, State.CacheInfo, State.GetCacheEntryOptions).ConfigureAwait(false));
            }

            State.CachedResult = await queryAsync().ConfigureAwait(false);

            await queryCache.SetAsync(State.CachedResult, State.CacheInfo, State.GetCacheEntryOptions).ConfigureAwait(false);

            return(State.CachedResult);
        }