public ValueTask <ArgumentBindingResult> BindAsync(ArgumentBinderContext context)
 {
     if (context.Parameter.ParameterInfo.ParameterType == typeof(CancellationToken))
     {
         var requestAborted = _httpContextAccessor.HttpContext.RequestAborted;
         return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Success(requestAborted)));
     }
     return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Failed()));
 }
Exemple #2
0
 public ValueTask <ArgumentBindingResult> BindAsync(ArgumentBinderContext context)
 {
     if (context.Parameter.ParameterInfo.ParameterType == typeof(HttpContext))
     {
         var httpContext = _httpContextAccessor.HttpContext;
         return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Success(httpContext)));
     }
     return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Failed()));
 }
Exemple #3
0
 public ValueTask <ArgumentBindingResult> BindAsync(ArgumentBinderContext context)
 {
     if (context.Parameter.ParameterInfo.ParameterType == typeof(GraphContext))
     {
         var graphContext = _httpContextAccessor.HttpContext.Features.Get <IGraphContextFeature>().GraphContext;
         return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Success(graphContext)));
     }
     return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Failed()));
 }
        public ValueTask <ArgumentBindingResult> BindAsync(ArgumentBinderContext context)
        {
            var serviceProvider = context.ResolverContext.GraphContext.RequestServices;
            var type            = context.Parameter.ParameterInfo.ParameterType;
            var argumentValue   = serviceProvider.GetService(type);

            if (null != argumentValue)
            {
                return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Success(argumentValue)));
            }
            return(new ValueTask <ArgumentBindingResult>(ArgumentBindingResult.Failed()));
        }