Extensions.cs 870 B

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