MqttUserProperty.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. namespace MQTTnet.Packets
  3. {
  4. public class MqttUserProperty
  5. {
  6. public MqttUserProperty(string name, string value)
  7. {
  8. Name = name ?? throw new ArgumentNullException(nameof(name));
  9. Value = value ?? throw new ArgumentNullException(nameof(value));
  10. }
  11. public string Name { get; }
  12. public string Value { get; }
  13. public override int GetHashCode()
  14. {
  15. return Name.GetHashCode() ^ Value.GetHashCode();
  16. }
  17. public override bool Equals(object other)
  18. {
  19. return Equals(other as MqttUserProperty);
  20. }
  21. public bool Equals(MqttUserProperty other)
  22. {
  23. if (other == null)
  24. {
  25. return false;
  26. }
  27. if (ReferenceEquals(other, this))
  28. {
  29. return true;
  30. }
  31. return string.Equals(Name, other.Name, StringComparison.Ordinal) &&
  32. string.Equals(Value, other.Value, StringComparison.Ordinal);
  33. }
  34. }
  35. }