Extensions.cs 795 B

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