Beispiel #1
0
        public object Convert(IHttpContext context, RouteResolveResponse route, ParameterInfo parameterInfo)
        {
            string body = string.Empty;

            using (var reader = new StreamReader(context.Request.InputStream))
            {
                body = reader.ReadToEnd();
            }

            if (string.IsNullOrEmpty(body))
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject(body, parameterInfo.ParameterType));
        }
Beispiel #2
0
        public object Convert(IHttpContext context, RouteResolveResponse route, ParameterInfo parameterInfo)
        {
            if (!route.QueryString.Any(f => f == parameterInfo.Name))
            {
                return(null);
            }
            bool isArray = parameterInfo.IsArray();

            if (isArray)
            {
                if (parameterInfo.ParameterType.GenericTypeArguments.Any())
                {
                    return(context.Request.QueryString[parameterInfo.Name].Split(',').Select(f => f).ToList());
                }
                else
                {
                    return(context.Request.QueryString[parameterInfo.Name].Split(',').Select(f => f).ToArray());
                }
            }
            else
            {
                return(System.Convert.ChangeType(context.Request.QueryString[parameterInfo.Name], parameterInfo.ParameterType));
            }
        }
 public object Convert(IHttpContext context, RouteResolveResponse route, ParameterInfo parameterInfo)
 {
     return(context.ToFormObject(parameterInfo.ParameterType));
 }
Beispiel #4
0
 public object Convert(IHttpContext context, RouteResolveResponse route, ParameterInfo parameterInfo)
 {
     return(new { });
 }