DeviceAvailableEventArgs.cs 2.0 KB

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