SsdpDeviceLocator.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Rssdp.Infrastructure;
  6. namespace Rssdp
  7. {
  8. // THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS
  9. // Be careful to check any changes compile and work for all platform projects it is shared in.
  10. /// <summary>
  11. /// Allows you to search the network for a particular device, device types, or UPnP service types. Also listenings for broadcast notifications of device availability and raises events to indicate changes in status.
  12. /// </summary>
  13. public sealed class SsdpDeviceLocator : SsdpDeviceLocatorBase
  14. {
  15. /// <summary>
  16. /// Default constructor. Constructs a new instance using the default <see cref="ISsdpCommunicationsServer"/> and <see cref="ISocketFactory"/> implementations for this platform.
  17. /// </summary>
  18. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="Can't expose along exception paths here (exceptions should be very rare anyway, and probably fatal too) and we shouldn't dipose the items we pass to base in any other case.")]
  19. public SsdpDeviceLocator() : base(new SsdpCommunicationsServer(new SocketFactory(null)))
  20. {
  21. // This is not the problem you are looking for;
  22. // Yes, this is poor man's dependency injection which some call an anti-pattern.
  23. // However, it makes the library really simple to get started with or to use if the calling code isn't using IoC/DI.
  24. // The fact we have injected dependencies is really an internal architectural implementation detail to allow for the
  25. // cross platform and testing concerns of this library. It shouldn't be something calling code worries about and is
  26. // not a deliberate extension point, except where adding new platform support in which case...
  27. // There is a constructor that takes a manually injected dependency anyway, so proper DI using
  28. // a container or whatever can be done anyway.
  29. }
  30. /// <summary>
  31. /// Full constructor. Constructs a new instance using the provided <see cref="ISsdpCommunicationsServer"/> implementation.
  32. /// </summary>
  33. public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer)
  34. : base(communicationsServer)
  35. {
  36. }
  37. }
  38. }