From c9eca8626bbf6b54298dfbd7b0c6f4167c66a6ba Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Mon, 7 Dec 2020 01:16:24 +0100 Subject: [PATCH] Add Cast.To(..) alternative to ApiMapper --- ln.http.api/WebApiController.cs | 4 ++++ ln.http.api/ln.http.api.csproj | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ln.http.api/WebApiController.cs b/ln.http.api/WebApiController.cs index 6e54f1c..ea865f3 100644 --- a/ln.http.api/WebApiController.cs +++ b/ln.http.api/WebApiController.cs @@ -9,6 +9,7 @@ using ln.http.exceptions; using ln.http.router; using ln.json; using ln.json.mapping; +using ln.type; namespace ln.http.api { @@ -92,6 +93,9 @@ namespace ln.http.api { if (!JSONMapper.DefaultMapper.Deserialize(jsonValue, parameterInfo.ParameterType, out arguments[n])) throw new BadRequestException(); + } else if (Cast.To(value, parameterInfo.ParameterType, out arguments[n])) + { + } else if (value is string text) { arguments[n] = TypeDescriptor.GetConverter(parameterInfo.ParameterType).ConvertFromInvariantString(text); diff --git a/ln.http.api/ln.http.api.csproj b/ln.http.api/ln.http.api.csproj index a1159a3..7b1d7ba 100644 --- a/ln.http.api/ln.http.api.csproj +++ b/ln.http.api/ln.http.api.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 true - 0.0.1 + 0.0.2-test Harald Wolff-Thobaben l--n.de Framework to create REST like APIs @@ -13,7 +13,7 @@ - +