Browse Source
Merge pull request #3508 from abpframework/maliming/DynamicHttpProxy
Dynamic C# proxying enhancements for culture sensitive types.
pull/3665/head
Halil İbrahim Kalkan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
16 deletions
-
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
-
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/UrlBuilder.cs
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
@ -106,18 +106,10 @@ namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
|
private async Task<T> MakeRequestAndGetResultAsync<T>(IAbpMethodInvocation invocation) |
|
|
|
{ |
|
|
|
var responseAsString = await MakeRequestAsync(invocation); |
|
|
|
|
|
|
|
//TODO: Think on that
|
|
|
|
if (TypeHelper.IsPrimitiveExtended(typeof(T), true)) |
|
|
|
|
|
|
|
if (typeof(T) == typeof(string)) |
|
|
|
{ |
|
|
|
if (typeof(DateTime).IsAssignableFrom(typeof(T))) |
|
|
|
{ |
|
|
|
return (T)(object)DateTime.Parse(responseAsString.Trim('\"'), CultureInfo.InvariantCulture); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return (T)Convert.ChangeType(responseAsString, typeof(T)); |
|
|
|
} |
|
|
|
return (T)Convert.ChangeType(responseAsString, typeof(T)); |
|
|
|
} |
|
|
|
|
|
|
|
return JsonSerializer.Deserialize<T>(responseAsString); |
|
|
|
|
|
|
|
@ -6,6 +6,7 @@ using System.Text; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Volo.Abp.Http.Modeling; |
|
|
|
using Volo.Abp.Http.ProxyScripting.Generators; |
|
|
|
using Volo.Abp.Localization; |
|
|
|
using Volo.Abp.Reflection; |
|
|
|
|
|
|
|
namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
|
@ -104,12 +105,15 @@ namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
|
|
|
|
|
private static string ConvertValueToString([NotNull] object value) |
|
|
|
{ |
|
|
|
if (value is DateTime dateTimeValue) |
|
|
|
using (CultureHelper.Use(CultureInfo.InvariantCulture)) |
|
|
|
{ |
|
|
|
return dateTimeValue.ToUniversalTime().ToString("u"); |
|
|
|
} |
|
|
|
if (value is DateTime dateTimeValue) |
|
|
|
{ |
|
|
|
return dateTimeValue.ToUniversalTime().ToString("u"); |
|
|
|
} |
|
|
|
|
|
|
|
return value.ToString(); |
|
|
|
return value.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|