jellyfin/Emby.Dlna/Ssdp/SsdpExtensions.cs

28 lines
676 B
C#
Raw Normal View History

#pragma warning disable CS1591
2020-05-25 23:52:51 +02:00
using System.Linq;
using System.Xml.Linq;
2016-10-30 00:22:20 +02:00
2016-10-30 00:34:54 +02:00
namespace Emby.Dlna.Ssdp
2016-10-30 00:22:20 +02:00
{
2020-08-20 21:04:57 +02:00
public static class SsdpExtensions
2016-10-30 00:22:20 +02:00
{
public static string? GetValue(this XElement container, XName name)
2016-10-30 00:22:20 +02:00
{
var node = container.Element(name);
2020-05-25 23:52:51 +02:00
return node?.Value;
2016-10-30 00:22:20 +02:00
}
public static string? GetAttributeValue(this XElement container, XName name)
2016-10-30 00:22:20 +02:00
{
var node = container.Attribute(name);
2020-05-25 23:52:51 +02:00
return node?.Value;
2016-10-30 00:22:20 +02:00
}
public static string? GetDescendantValue(this XElement container, XName name)
2020-05-25 23:52:51 +02:00
=> container.Descendants(name).FirstOrDefault()?.Value;
2016-10-30 00:22:20 +02:00
}
}