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

            return(GetRequest(data, context));
        }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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
            });
        }
Ejemplo n.º 5
0
 protected override object GetRequest(string data,
                                      RequestReaderContext context)
 {
     return(JsonConvert.DeserializeObject(data, context.RequestContext
                                          .Route.RequestParameter.ParameterType.Type, _settings));
 }
Ejemplo n.º 6
0
 public virtual bool AppliesTo(RequestReaderContext context)
 {
     return(context.RequestContext.Route.HasRequest && context
            .RequestContext.RequestMessage.ContentTypeIs(_mimeTypes));
 }
Ejemplo n.º 7
0
 protected abstract object GetRequest(string data, RequestReaderContext context);
Ejemplo n.º 8
0
 protected override object GetRequest(string data, RequestReaderContext context)
 {
     return(data.DeserializeXml(context.RequestContext.Route
                                .RequestParameter.ParameterType.Type, Encoding.UTF8));
 }
Ejemplo n.º 9
0
 public override bool AppliesTo(RequestReaderContext context)
 {
     return(context.RequestContext.Route.HasRequest && base.AppliesTo(context));
 }