Beispiel #1
0
        public async Task <object> Read(RequestReaderContext context)
        {
            var data = await context.RequestContext.RequestMessage
                       .Content.ReadAsStringAsync();

            return(GetRequest(data, context));
        }
Beispiel #2
0
 protected override object GetRequest(string data,
                                      RequestReaderContext context)
 {
     return(context.RequestContext.Route.RequestParameter.ParameterType
            .CreateAndBind(HttpUtility.ParseQueryString(data).ToObjectLookup(),
                           (p, v) => _mappers.Map(v, p, context.RequestContext, _configuration)));
 }
Beispiel #3
0
        public virtual bool AppliesTo(RequestReaderContext context)
        {
            var requestType = context.RequestContext.Route.RequestParameter?.ParameterType.Type;

            return(context.RequestContext.Route.HasRequest &&
                   (requestType == typeof(InputStream) || requestType == typeof(Stream)));
        }
Beispiel #4
0
        public async Task <object> Read(RequestReaderContext context)
        {
            var requestType = context.RequestContext.Route.RequestParameter?.ParameterType.Type;
            var stream      = await context.RequestContext.RequestMessage.Content.ReadAsStreamAsync();

            if (requestType == typeof(Stream))
            {
                return(stream);
            }
            var headers = context.RequestContext.RequestMessage.Content.Headers;

            return(new InputStream
            {
                Filename = headers.ContentDisposition?.FileName.Trim('"'),
                MimeType = headers.ContentType?.MediaType,
                Length = headers.ContentLength,
                Stream = stream
            });
        }
Beispiel #5
0
 protected override object GetRequest(string data,
                                      RequestReaderContext context)
 {
     return(JsonConvert.DeserializeObject(data, context.RequestContext
                                          .Route.RequestParameter.ParameterType.Type, _settings));
 }
Beispiel #6
0
 public virtual bool AppliesTo(RequestReaderContext context)
 {
     return(context.RequestContext.Route.HasRequest && context
            .RequestContext.RequestMessage.ContentTypeIs(_mimeTypes));
 }
Beispiel #7
0
 protected abstract object GetRequest(string data, RequestReaderContext context);
Beispiel #8
0
 protected override object GetRequest(string data, RequestReaderContext context)
 {
     return(data.DeserializeXml(context.RequestContext.Route
                                .RequestParameter.ParameterType.Type, Encoding.UTF8));
 }
Beispiel #9
0
 public override bool AppliesTo(RequestReaderContext context)
 {
     return(context.RequestContext.Route.HasRequest && base.AppliesTo(context));
 }