Example #1
0
        public override async Task <InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
        {
            var stream = context.HttpContext.Request.Body;

            string data = null;

            using (var reader = context.ReaderFactory(stream, encoding))
            {
                data = await reader.ReadToEndAsync();
            }

            // TODO: VC: Can also have PlainText reader, which just reads the entire string and then parses it

            Type type = context.ModelType;

            var response = _csvSerializationService.Deserialize(data, type);

            return(InputFormatterResult.Success(response));
        }