Skip to content

Commit

Permalink
2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Roc committed Jan 9, 2019
1 parent ea31a45 commit 74c659d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 24 deletions.
6 changes: 3 additions & 3 deletions common.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project>
<PropertyGroup>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<NoWarn>$(NoWarn);CS1570;CS1591</NoWarn>
<Description>Essensoft.AspNetCore.Payment</Description>
<Copyright>© Essensoft 2018</Copyright>
<Copyright>© Essensoft 2019</Copyright>
<PackageIconUrl>https://raw.githubusercontent.com/Essensoft/Payment/master/images/Payment.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/Essensoft/Payment</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Essensoft/Payment</RepositoryUrl>
<License>https://raw.githubusercontent.com/Essensoft/Payment/master/LICENSE</License>
<PackageLicenseUrl>https://raw.githubusercontent.com/Essensoft/Payment/master/LICENSE</PackageLicenseUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release' ">
Expand Down
2 changes: 1 addition & 1 deletion samples/WebApplicationSample/WebApplicationSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
<PackageReference Include="QRCoder" Version="1.3.5" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public static class HttpClientExtensions
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="client">HttpClient</param>
/// <param name="url">请求地址</param>
/// <param name="content">请求内容</param>
/// <returns>HTTP响应</returns>
/// <param name="mediaType">媒体类型</param>
/// <returns>HTTP响应内容</returns>
public static async Task<string> DoPostAsync(this HttpClient client, string url, string content, string mediaType = "application/xml")
{
using (var requestContent = new StringContent(content, Encoding.UTF8, mediaType))
Expand Down
26 changes: 12 additions & 14 deletions src/Essensoft.AspNetCore.Payment.JDPay/Utility/JDPayUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,21 @@ internal static bool HasTextXmlContentType(this HttpRequest request)
/// <summary>
/// 尝试将对象实例转换成目标类型
/// </summary>
/// <typeparam name="T">对象实例类型</typeparam>
/// <typeparam name="R">目标类型</typeparam>
/// <param name="Object">对象实例</param>
/// <param name="DefaultValue">默认值</param>
/// <param name="obj">对象实例</param>
/// <param name="destinationType">目的类型</param>
/// <returns>转换后类型</returns>
internal static object TryTo(this object Object, Type destinationType)
internal static object TryTo(this object obj, Type destinationType)
{
try
{
if (Object == null || Convert.IsDBNull(Object))
if (obj == null || Convert.IsDBNull(obj))
{
return GetDefault(destinationType);
}

if (Object as string != null)
if (obj as string != null)
{
var ObjectValue = Object as string;
var ObjectValue = obj as string;
if (destinationType.IsEnum)
{
return Enum.Parse(destinationType, ObjectValue, true);
Expand All @@ -71,22 +69,22 @@ internal static object TryTo(this object Object, Type destinationType)
return GetDefault(destinationType);
}
}
if (Object as IConvertible != null)
if (obj as IConvertible != null)
{
var destination =
destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable<>) ?
Nullable.GetUnderlyingType(destinationType) : destinationType;
return Convert.ChangeType(Object, destination);
return Convert.ChangeType(obj, destination);
}
if (destinationType.IsAssignableFrom(Object.GetType()))
if (destinationType.IsAssignableFrom(obj.GetType()))
{
return Object;
return obj;
}

var Converter = TypeDescriptor.GetConverter(Object.GetType());
var Converter = TypeDescriptor.GetConverter(obj.GetType());
if (Converter.CanConvertTo(destinationType))
{
return Converter.ConvertTo(Object, destinationType);
return Converter.ConvertTo(obj, destinationType);
}
}
catch { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public static class HttpClientExtensions
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="client">HttpClient</param>
/// <param name="url">请求地址</param>
/// <param name="content">请求内容</param>
/// <returns>HTTP响应</returns>
/// <returns>HTTP响应内容</returns>
public static async Task<string> DoPostAsync(this HttpClient client, string url, string content)
{
using (var requestContent = new StringContent(content, Encoding.UTF8, "application/json"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public static class HttpClientExtensions
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="client">HttpClient</param>
/// <param name="url">请求地址</param>
/// <param name="content">请求参数</param>
/// <returns>HTTP响应</returns>
/// <param name="content">请求内容</param>
/// <returns>HTTP响应内容</returns>
public static async Task<string> DoPostAsync(this HttpClient client, string url, string content)
{
using (var requestContent = new StringContent(content, Encoding.UTF8, "application/xml"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public static class HttpClientExtensions
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="client">HttpClient</param>
/// <param name="url">请求地址</param>
/// <param name="content">请求参数</param>
/// <returns>HTTP响应</returns>
/// <param name="content">请求内容</param>
/// <returns>HTTP响应内容</returns>
public static async Task<string> DoPostAsync(this HttpClient client, string url, string content)
{
using (var requestContent = new StringContent(content, Encoding.UTF8, "application/xml"))
Expand Down

0 comments on commit 74c659d

Please sign in to comment.