Extensions.cs 828 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Net;
  3. using System.Threading.Tasks;
  4. using System.Xml.Linq;
  5. namespace Emby.Dlna.Ssdp
  6. {
  7. public static class Extensions
  8. {
  9. public static string GetValue(this XElement container, XName name)
  10. {
  11. var node = container.Element(name);
  12. return node == null ? null : node.Value;
  13. }
  14. public static string GetAttributeValue(this XElement container, XName name)
  15. {
  16. var node = container.Attribute(name);
  17. return node == null ? null : node.Value;
  18. }
  19. public static string GetDescendantValue(this XElement container, XName name)
  20. {
  21. foreach (var node in container.Descendants(name))
  22. {
  23. return node.Value;
  24. }
  25. return null;
  26. }
  27. }
  28. }