mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 09:13:02 +08:00
17 lines
604 B
C#
17 lines
604 B
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace MQTTnet.Extensions
|
|
{
|
|
public static class UserPropertyExtension
|
|
{
|
|
public static string GetUserProperty(this MqttApplicationMessage message, string propertyName, StringComparison comparisonType = StringComparison.Ordinal)
|
|
{
|
|
if (message == null) throw new ArgumentNullException(nameof(message));
|
|
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
|
|
|
|
return message.UserProperties?.SingleOrDefault(up => up.Name.Equals(propertyName, comparisonType))?.Value;
|
|
}
|
|
}
|
|
}
|