@@ -1,4 +1,5 @@ | |||||
using System; | using System; | ||||
using System.ComponentModel; | |||||
using System.Linq; | using System.Linq; | ||||
namespace MQTTnet.Extensions | namespace MQTTnet.Extensions | ||||
@@ -17,9 +18,10 @@ namespace MQTTnet.Extensions | |||||
{ | { | ||||
var value = GetUserProperty(message, propertyName, comparisonType); | var value = GetUserProperty(message, propertyName, comparisonType); | ||||
var typeDescriptor = TypeDescriptor.GetConverter(typeof(T)); | |||||
try | try | ||||
{ | { | ||||
return (T) Convert.ChangeType(value, typeof(T)); | |||||
return (T) typeDescriptor.ConvertFromString(value); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -42,6 +42,7 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.3'"> | <ItemGroup Condition="'$(TargetFramework)'=='netstandard1.3'"> | ||||
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" /> | |||||
<PackageReference Include="System.Net.Security" Version="4.3.2" /> | <PackageReference Include="System.Net.Security" Version="4.3.2" /> | ||||
<PackageReference Include="System.Net.WebSockets" Version="4.3.0" /> | <PackageReference Include="System.Net.WebSockets" Version="4.3.0" /> | ||||
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2" /> | <PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2" /> | ||||