Extensions.cs 836 B

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