瀏覽代碼

Fix.

release/3.x.x
PMExtra 4 年之前
父節點
當前提交
aafd4ea658
共有 2 個檔案被更改,包括 2 行新增2 行删除
  1. +1
    -1
      Build/MQTTnet.nuspec
  2. +1
    -1
      Source/MQTTnet/Extensions/UserPropertyExtension.cs

+ 1
- 1
Build/MQTTnet.nuspec 查看文件

@@ -22,7 +22,7 @@
* [Server] Added interceptor for unsubscriptions.
* [MQTTnet.Server] Added interceptor for unsubscriptions.
* [MQTTnet.AspNetCore] improved compatibility with AspNetCore 3.1
* [MqttApplicationMessage] Added GetUserProperty<T> convenience method (thanks to @PMExtra).
* [Core] Added MqttApplicationMessage.GetUserProperty&lt;T&gt;() convenience method (thanks to @PMExtra).
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2019</copyright>
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags>


+ 1
- 1
Source/MQTTnet/Extensions/UserPropertyExtension.cs 查看文件

@@ -7,7 +7,7 @@ namespace MQTTnet.Extensions
{
public static string GetUserProperty(this MqttApplicationMessage message, string propertyName, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
{
return message.UserProperties.SingleOrDefault(up => up.Name.Equals(propertyName, comparisonType))?.Value;
return message?.UserProperties?.SingleOrDefault(up => up.Name.Equals(propertyName, comparisonType))?.Value;
}

public static T GetUserProperty<T>(this MqttApplicationMessage message, string propertyName, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)


Loading…
取消
儲存