DeviceAvailableEventArgs.cs 2.0 KB

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