UpnpDevice.cs 924 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Net;
  3. namespace Emby.Dlna.Server
  4. {
  5. public sealed class UpnpDevice
  6. {
  7. public readonly Uri Descriptor;
  8. public readonly string Type;
  9. public readonly string USN;
  10. public readonly string Uuid;
  11. public readonly IPAddress Address;
  12. public UpnpDevice(string aUuid, string aType, Uri aDescriptor, IPAddress address)
  13. {
  14. Uuid = aUuid;
  15. Type = aType;
  16. Descriptor = aDescriptor;
  17. Address = address;
  18. USN = CreateUSN(aUuid, aType);
  19. }
  20. private static string CreateUSN(string aUuid, string aType)
  21. {
  22. if (aType.StartsWith("uuid:", StringComparison.OrdinalIgnoreCase))
  23. {
  24. return aType;
  25. }
  26. else
  27. {
  28. return String.Format("uuid:{0}::{1}", aUuid, aType);
  29. }
  30. }
  31. }
  32. }