DeviceUnavailableEventArgs.cs 1.9 KB

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