DeviceUnavailableEventArgs.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #region Fields
  10. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  11. private readonly bool _Expired;
  12. #endregion
  13. #region Constructors
  14. /// <summary>
  15. /// Full constructor.
  16. /// </summary>
  17. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>
  18. /// <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>
  19. /// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  20. public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)
  21. {
  22. if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
  23. _DiscoveredDevice = discoveredDevice;
  24. _Expired = expired;
  25. }
  26. #endregion
  27. #region Public Properties
  28. /// <summary>
  29. /// 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.
  30. /// </summary>
  31. public bool Expired
  32. {
  33. get { return _Expired; }
  34. }
  35. /// <summary>
  36. /// A reference to a <see cref="DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.
  37. /// </summary>
  38. public DiscoveredSsdpDevice DiscoveredDevice
  39. {
  40. get { return _DiscoveredDevice; }
  41. }
  42. #endregion
  43. }
  44. }