Browse Source

Fix.

release/3.x.x
PMExtra 4 years ago
parent
commit
aafd4ea658
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      Build/MQTTnet.nuspec
  2. +1
    -1
      Source/MQTTnet/Extensions/UserPropertyExtension.cs

+ 1
- 1
Build/MQTTnet.nuspec View File

@@ -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 View File

@@ -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…
Cancel
Save