DeviceAvailableEventArgs.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Net;
  3. namespace Rssdp
  4. {
  5. /// <summary>
  6. /// Event arguments for the <see cref="Infrastructure.SsdpDeviceLocatorBase.DeviceAvailable"/> event.
  7. /// </summary>
  8. public sealed class DeviceAvailableEventArgs : EventArgs
  9. {
  10. public IPAddress LocalIpAddress { get; set; }
  11. #region Fields
  12. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  13. private readonly bool _IsNewlyDiscovered;
  14. #endregion
  15. #region Constructors
  16. /// <summary>
  17. /// Full constructor.
  18. /// </summary>
  19. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the available device.</param>
  20. /// <param name="isNewlyDiscovered">A boolean value indicating whether or not this device came from the cache. See <see cref="IsNewlyDiscovered"/> for more detail.</param>
  21. /// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  22. public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered)
  23. {
  24. if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
  25. _DiscoveredDevice = discoveredDevice;
  26. _IsNewlyDiscovered = isNewlyDiscovered;
  27. }
  28. #endregion
  29. #region Public Properties
  30. /// <summary>
  31. /// 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.
  32. /// </summary>
  33. public bool IsNewlyDiscovered
  34. {
  35. get { return _IsNewlyDiscovered; }
  36. }
  37. /// <summary>
  38. /// A reference to a <see cref="DiscoveredSsdpDevice"/> instance containing the discovered details and allowing access to the full device description.
  39. /// </summary>
  40. public DiscoveredSsdpDevice DiscoveredDevice
  41. {
  42. get { return _DiscoveredDevice; }
  43. }
  44. #endregion
  45. }
  46. }