-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathRssSource.cs
More file actions
56 lines (48 loc) · 1.2 KB
/
RssSource.cs
File metadata and controls
56 lines (48 loc) · 1.2 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Xml;
using Waher.Content.Xml;
using Waher.Runtime.Collections;
namespace Waher.Content.Rss
{
/// <summary>
/// RSS channel that the item came from.
/// </summary>
public class RssSource
{
/// <summary>
/// RSS channel that the item came from.
/// </summary>
/// <param name="Xml">XML Definition</param>
/// <param name="BaseUri">Base URI</param>
public RssSource(XmlElement Xml, Uri BaseUri)
{
if (Xml is null)
throw new ArgumentNullException(nameof(Xml));
ChunkedList<RssWarning> Warnings = new ChunkedList<RssWarning>();
this.Title = Xml.InnerText;
if (Xml.HasAttribute("url"))
{
string s = XML.Attribute(Xml, "url");
if (Uri.TryCreate(BaseUri, s, out Uri Url))
this.Url = Url;
else
Warnings.Add(new RssWarning(Xml, "Invalid URI: " + s));
}
else
this.Url = null;
this.Warnings = Warnings.ToArray();
}
/// <summary>
/// Any warning messages created during parsing.
/// </summary>
public RssWarning[] Warnings { get; }
/// <summary>
/// URL to the source.
/// </summary>
public Uri Url { get; } = null;
/// <summary>
/// Title of the source.
/// </summary>
public string Title { get; }
}
}