From b553f74ef88d8b15581ae02908a1285eedf3c096 Mon Sep 17 00:00:00 2001 From: yekalkan Date: Tue, 26 Sep 2017 15:29:54 +0300 Subject: [PATCH] Should not use json serializer for primitive return types. --- .../DynamicProxying/DynamicHttpProxyInterceptor.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs index f9ce970f36..fbd533dbba 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Reflection; @@ -9,6 +10,7 @@ using Volo.Abp.DynamicProxy; using Volo.Abp.Http.Modeling; using Volo.Abp.Http.ProxyScripting.Generators; using Volo.Abp.Json; +using Volo.Abp.Reflection; using Volo.Abp.Threading; namespace Volo.Abp.Http.Client.DynamicProxying @@ -77,7 +79,15 @@ namespace Volo.Abp.Http.Client.DynamicProxying private async Task MakeRequestAndGetResultAsync(IAbpMethodInvocation invocation) { - return _jsonSerializer.Deserialize(await MakeRequest(invocation)); + var responseAsString = await MakeRequest(invocation); + + //TODO: Think on that + if (TypeHelper.IsPrimitiveExtendedIncludingNullable(typeof(T), true)) + { + return (T)Convert.ChangeType(responseAsString, typeof(T)); + } + + return _jsonSerializer.Deserialize(responseAsString); } private async Task MakeRequest(IAbpMethodInvocation invocation)