Exemplo n.º 1
0
        public async Task Invoke(HttpContext context)
        {
            //сохраним в HttpContext все значения таргетирования, как из синхронных провайдеров, так и асинхронных
            var targetingKeys = new List <string>();

            var getValuesTasks = _targetingConfigurationBuilderForAsync.GetServices(context.RequestServices).Select(tp => tp.GetValues());
            await Task.WhenAll(getValuesTasks);

            foreach (var dict in getValuesTasks
                     .Select(t => t.Result)
                     .Union(_targetingConfigurationBuilder.GetServices(context.RequestServices).Select(tp => tp.GetValues()))
                     .Where(dict => dict != null))
            {
                foreach (var key in dict.Keys)
                {
                    context.Items[key] = dict[key];
                    targetingKeys.Add(key);
                }
            }

            //сохраним в HttpContext все полученные ключи таргетирования
            context.Items[HttpTargetingContext.TargetingKeysContextKey] = targetingKeys.Distinct().ToArray();

            // Call the next delegate/middleware in the pipeline
            await _next(context);
        }
Exemplo n.º 2
0
        private Dictionary <string, IEnumerable <string> > GetFullDictionary()
        {
            var result = new Dictionary <string, IEnumerable <string> >();

            foreach (var provider in _registeredProviders.GetServices(_httpContextAccessor.HttpContext.RequestServices))
            {
                var dict = provider.GetPossibleValues();
                foreach (var key in dict.Keys)
                {
                    result[key] = dict[key];
                }
            }

            return(result);
        }
Exemplo n.º 3
0
 public IEnumerable <ICacheTagTracker> Get(IServiceProvider provider)
 {
     return(_cfg.GetServices(provider ?? _sp));
 }
Exemplo n.º 4
0
 public ITargetingFilter Get()
 {
     return(new UnitedFilter(_cfg.GetServices(_httpContextAccessor.HttpContext.RequestServices)));
 }