DeviceUnavailableEventArgs.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. namespace Rssdp
  6. {
  7. /// <summary>
  8. /// Event arguments for the <see cref="Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.
  9. /// </summary>
  10. public sealed class DeviceUnavailableEventArgs : EventArgs
  11. {
  12. #region Fields
  13. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  14. private readonly bool _Expired;
  15. #endregion
  16. #region Constructors
  17. /// <summary>
  18. /// Full constructor.
  19. /// </summary>
  20. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>
  21. /// <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>
  22. /// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  23. public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)
  24. {
  25. if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
  26. _DiscoveredDevice = discoveredDevice;
  27. _Expired = expired;
  28. }
  29. #endregion
  30. #region Public Properties
  31. /// <summary>
  32. /// 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.
  33. /// </summary>
  34. public bool Expired
  35. {
  36. get { return _Expired; }
  37. }
  38. /// <summary>
  39. /// A reference to a <see cref="DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.
  40. /// </summary>
  41. public DiscoveredSsdpDevice DiscoveredDevice
  42. {
  43. get { return _DiscoveredDevice; }
  44. }
  45. #endregion
  46. }
  47. }