aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna/Ssdp/Extensions.cs
blob: 41a361515b65e2092659078ca58c3f9729e4843c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Net;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Emby.Dlna.Ssdp
{
    public static class Extensions
    {
        public static string GetValue(this XElement container, XName name)
        {
            var node = container.Element(name);

            return node == null ? null : node.Value;
        }

        public static string GetAttributeValue(this XElement container, XName name)
        {
            var node = container.Attribute(name);

            return node == null ? null : node.Value;
        }

        public static string GetDescendantValue(this XElement container, XName name)
        {
            foreach (var node in container.Descendants(name))
            {
                return node.Value;
            }

            return null;
        }
    }
}