コード例 #1
0
        private async Task <BindResult> Read(HttpContent content,
                                             ParameterDescriptor requestParameter,
                                             RequestBinderContext context)
        {
            var readContext = content.CreateReaderContext(_actionDescriptor);
            var reader      = _actionDescriptor.RequestReaders
                              .ThatApplyToOrDefault(_readers, readContext)
                              .FirstOrDefault();

            if (reader == null)
            {
                return(BindResult.NoReader());
            }

            var result = await reader.Read(readContext);

            if (result.Status == ReadStatus.Failure)
            {
                return(BindResult.Failure(result.ErrorMessage));
            }
            context.ActionArguments[requestParameter.Position] = result.Value;
            return(BindResult.Success());
        }