Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RssEnclosure.cs
1using System;
2using System.Collections.Generic;
3using System.Xml;
5
6namespace Waher.Content.Rss
7{
11 public class RssEnclosure
12 {
18 public RssEnclosure(XmlElement Xml, Uri BaseUri)
19 {
20 if (Xml is null)
21 throw new ArgumentNullException(nameof(Xml));
22
23 List<RssWarning> Warnings = new List<RssWarning>();
24
25 string s = XML.Attribute(Xml, "url");
26 if (Uri.TryCreate(BaseUri, s, out Uri Url))
27 this.Url = Url;
28 else
29 Warnings.Add(new RssWarning(Xml, "Invalid URL: " + Xml.OuterXml));
30
31 this.Length = XML.Attribute(Xml, "length", 0L);
32 if (this.Length <= 0)
33 Warnings.Add(new RssWarning(Xml, "Invalid Length: " + Xml.OuterXml));
34
35 this.ContentType = XML.Attribute(Xml, "type");
36 if (string.IsNullOrEmpty(ContentType))
37 Warnings.Add(new RssWarning(Xml, "Invalid Content-Type: " + Xml.OuterXml));
38
39 this.Warnings = Warnings.ToArray();
40 }
41
45 public RssWarning[] Warnings { get; }
46
50 public Uri Url { get; } = null;
51
55 public long Length { get; }
56
60 public string ContentType { get; }
61 }
62}
Describes content enclosed in an RSS item.
Definition: RssEnclosure.cs:12
RssWarning[] Warnings
Any warning messages created during parsing.
Definition: RssEnclosure.cs:45
string ContentType
Content-Type of content
Definition: RssEnclosure.cs:60
RssEnclosure(XmlElement Xml, Uri BaseUri)
Describes content enclosed in an RSS item.
Definition: RssEnclosure.cs:18
Uri Url
URL to the content.
Definition: RssEnclosure.cs:50
long Length
Length of content.
Definition: RssEnclosure.cs:55
Contains a warning message.
Definition: RssWarning.cs:9
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914