DeviceUnavailableEventArgs.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. namespace Rssdp
  3. {
  4. /// <summary>
  5. /// Event arguments for the <see cref="Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.
  6. /// </summary>
  7. public sealed class DeviceUnavailableEventArgs : EventArgs
  8. {
  9. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  10. private readonly bool _Expired;
  11. /// <summary>
  12. /// Full constructor.
  13. /// </summary>
  14. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>
  15. /// <param name="expired">A boolean value indicating whether this device is unavailable because it expired, or because it explicitly sent a byebye notification.. See <see cref="Expired"/> for more detail.</param>
  16. /// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  17. public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)
  18. {
  19. if (discoveredDevice == null)
  20. {
  21. throw new ArgumentNullException(nameof(discoveredDevice));
  22. }
  23. _DiscoveredDevice = discoveredDevice;
  24. _Expired = expired;
  25. }
  26. /// <summary>
  27. /// Returns true if the device is considered unavailable because it's cached information expired before a new alive notification or search result was received. Returns false if the device is unavailable because it sent an explicit notification of it's unavailability.
  28. /// </summary>
  29. public bool Expired
  30. {
  31. get { return _Expired; }
  32. }
  33. /// <summary>
  34. /// A reference to a <see cref="DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.
  35. /// </summary>
  36. public DiscoveredSsdpDevice DiscoveredDevice
  37. {
  38. get { return _DiscoveredDevice; }
  39. }
  40. }
  41. }