예제 #1
0
        public async Task <BindResult> Bind(RequestBinderContext context)
        {
            var data = await _requestMessage.Content.ReadAsStringAsync();

            return(_argumentBinder.Bind(data.ParseQueryString(), context.ActionArguments,
                                        _routeDescriptor.Parameters));
        }
예제 #2
0
        public Task <BindResult> Bind(RequestBinderContext context)
        {
            var parameters = _routeDescriptor.Parameters
                             .Where(x => IncludeParameter(x, _configuration.RequestInfoBindingMode)).ToArray();

            return(_argumentBinder.Bind(_requestProperties.GetProperties().ToLookup(),
                                        context.ActionArguments, parameters, MapParameterName).ToTaskResult());
        }
예제 #3
0
        public async Task <BindResult> Bind(RequestBinderContext context)
        {
            var data = await _requestMessage.Content.ReadAsStringAsync();

            var values = JsonConvert.DeserializeObject <Dictionary <string, object> >(data).ToLookup();

            return(_argumentBinder.Bind(values, context.ActionArguments, _routeDescriptor.Parameters));
        }
예제 #4
0
        public Task <BindResult> Bind(RequestBinderContext context)
        {
            var values     = _requestMessage.Headers.ToLookup();
            var parameters = _routeDescriptor.Parameters
                             .Where(x => IncludeParameter(x, _configuration.HeadersBindingMode)).ToArray();

            return(_argumentBinder.Bind(values, context.ActionArguments,
                                        parameters, MapParameterName).ToTaskResult());
        }
예제 #5
0
        public Task <BindResult> Bind(RequestBinderContext context)
        {
            var values = _urlParameters.SelectMany(x =>
                                                   ExpandWildcardParameters(x, _routeDescriptor
                                                                            .UrlParameters)).ToLookup();
            var parameters = _routeDescriptor.UrlParameters
                             .Concat(_routeDescriptor.Parameters).ToArray();

            return(_argumentBinder.Bind(values, context.ActionArguments,
                                        parameters).ToTaskResult());
        }
예제 #6
0
        private BindResult BindValues(List <KeyValuePair <string, object> > values,
                                      RequestBinderContext context)
        {
            if (!values.Any())
            {
                return(BindResult.Success());
            }

            var valueLookup = values.ToLookup();

            if (_actionDescriptor.Route.Parameters.Any())
            {
                var result = _argumentBinder.Bind(valueLookup,
                                                  context.ActionArguments, _actionDescriptor.Route.Parameters);
                if (result.Status == BindingStatus.Failure)
                {
                    return(result);
                }
            }

            if (!_actionDescriptor.Route.HasRequest)
            {
                return(BindResult.Success());
            }

            var requestParameter = _actionDescriptor.Route.RequestParameter;

            if (IsEnumerableStream(requestParameter.ParameterType))
            {
                return(BindResult.Success());
            }

            var instance = EnsureRequestValue(context, requestParameter);

            var actionParameters = requestParameter.ParameterType.Properties
                                   .Select(x => new ActionParameter(_actionDescriptor.Action, requestParameter, x));

            return(_parameterBinder.Bind(valueLookup, actionParameters,
                                         (p, v) => p.BindProperty(instance, v),
                                         BindResult.Success, BindResult.Failure));
        }
예제 #7
0
 public Task <BindResult> Bind(RequestBinderContext context)
 {
     return(_argumentBinder.Bind(_querystringParameters,
                                 context.ActionArguments, _routeDescriptor.Parameters)
            .ToTaskResult());
 }
예제 #8
0
        public async Task <BindResult> Bind(RequestBinderContext context)
        {
            var values = await GetValues();

            return(_argumentBinder.Bind(values, context.ActionArguments, _routeDescriptor.Parameters));
        }