Esempio n. 1
0
        protected async Task <IReadOnlyQueryRequest> BuildRequestAsync(
            HttpContext context,
            IServiceProvider services,
            IQueryRequestBuilder builder)
        {
            if (!_interceptorInitialized)
            {
                _interceptor = services
                               .GetService <IQueryRequestInterceptor <HttpContext> >();
                _interceptorInitialized = true;
            }

            if (_interceptor != null)
            {
                await _interceptor.OnCreateAsync(
                    context,
                    builder,
                    context.GetCancellationToken())
                .ConfigureAwait(false);
            }

            builder.SetServices(services);
            builder.TryAddProperty(nameof(HttpContext), context);
            builder.TryAddProperty(nameof(ClaimsPrincipal), context.GetUser());

            if (context.IsTracingEnabled())
            {
                builder.TryAddProperty(ContextDataKeys.EnableTracing, true);
            }

            return(builder.Create());
        }
Esempio n. 2
0
        public Task OnCreateAsync(
            ISocketConnection context,
            IQueryRequestBuilder requestBuilder,
            CancellationToken cancellationToken)
        {
            if (_interceptor != null &&
                context is WebSocketConnection connection)
            {
                return(_interceptor.OnCreateAsync(
                           connection.HttpContext,
                           requestBuilder,
                           cancellationToken));
            }

            return(Task.CompletedTask);
        }