Extensions.cs 763 B

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