DeviceAvailableEventArgs.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.DeviceAvailable"/> event.
  10. /// </summary>
  11. public sealed class DeviceAvailableEventArgs : EventArgs
  12. {
  13. #region Fields
  14. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  15. private readonly bool _IsNewlyDiscovered;
  16. #endregion
  17. #region Constructors
  18. /// <summary>
  19. /// Full constructor.
  20. /// </summary>
  21. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the available device.</param>
  22. /// <param name="isNewlyDiscovered">A boolean value indicating whether or not this device came from the cache. See <see cref="IsNewlyDiscovered"/> for more detail.</param>
  23. /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  24. public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered)
  25. {
  26. if (discoveredDevice == null) throw new ArgumentNullException("discoveredDevice");
  27. _DiscoveredDevice = discoveredDevice;
  28. _IsNewlyDiscovered = isNewlyDiscovered;
  29. }
  30. #endregion
  31. #region Public Properties
  32. /// <summary>
  33. /// Returns true if the device was discovered due to an alive notification, or a search and was not already in the cache. Returns false if the item came from the cache but matched the current search request.
  34. /// </summary>
  35. public bool IsNewlyDiscovered
  36. {
  37. get { return _IsNewlyDiscovered; }
  38. }
  39. /// <summary>
  40. /// A reference to a <see cref="Rssdp.DiscoveredSsdpDevice"/> instance containing the discovered details and allowing access to the full device description.
  41. /// </summary>
  42. public DiscoveredSsdpDevice DiscoveredDevice
  43. {
  44. get { return _DiscoveredDevice; }
  45. }
  46. #endregion
  47. }
  48. }