Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RssImage.cs
1using System;
2using System.Collections.Generic;
3using System.Xml;
4
5namespace Waher.Content.Rss
6{
10 public class RssImage
11 {
17 public RssImage(XmlElement Xml, Uri BaseUri)
18 {
19 if (Xml is null)
20 throw new ArgumentNullException(nameof(Xml));
21
22 List<RssWarning> Warnings = new List<RssWarning>();
23
24 foreach (XmlNode N in Xml.ChildNodes)
25 {
26 if (!(N is XmlElement E))
27 continue;
28
29 if (E.NamespaceURI == Xml.NamespaceURI)
30 {
31 switch (E.LocalName)
32 {
33 case "url":
34 if (Uri.TryCreate(BaseUri, E.InnerText, out Uri Url))
35 this.Url = Url;
36 else
37 Warnings.Add(new RssWarning(E, "Invalid URI: " + E.InnerText));
38 break;
39
40 case "title":
41 this.Title = E.InnerText;
42 break;
43
44 case "link":
45 if (Uri.TryCreate(BaseUri, E.InnerText, out Uri Link))
46 this.Link = Link;
47 else
48 Warnings.Add(new RssWarning(E, "Invalid URI: " + E.InnerText));
49 break;
50
51 case "width":
52 if (int.TryParse(E.InnerText, out int Width) && Width > 0 && Width <= 144)
53 this.Width = Width;
54 else
55 Warnings.Add(new RssWarning(E, "Invalid Width: " + E.InnerText));
56 break;
57
58 case "height":
59 if (int.TryParse(E.InnerText, out int Height) && Height > 0 && Height <= 400)
60 this.Height = Height;
61 else
62 Warnings.Add(new RssWarning(E, "Invalid Height: " + E.InnerText));
63 break;
64
65 case "description":
66 this.Description = E.InnerText;
67 break;
68
69 default:
70 Warnings.Add(new RssWarning(E));
71 break;
72 }
73 }
74 else
75 Warnings.Add(new RssWarning(E));
76 }
77
78 this.Warnings = Warnings.ToArray();
79 }
80
84 public RssWarning[] Warnings { get; }
85
89 public Uri Url { get; } = null;
90
95 public string Title { get; }
96
102 public Uri Link { get; } = null;
103
107 public int Width { get; } = 88;
108
112 public int Height { get; } = 31;
113
118 public string Description { get; }
119 }
120}
Specifies a GIF, JPEG or PNG image that can be displayed with the channel.
Definition: RssImage.cs:11
int Width
Width of image in pixels.
Definition: RssImage.cs:107
string Title
Describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendere...
Definition: RssImage.cs:95
int Height
Height of image in pixels.
Definition: RssImage.cs:112
RssWarning[] Warnings
Any warning messages created during parsing.
Definition: RssImage.cs:84
Uri Url
URL of a GIF, JPEG or PNG image that represents the channel.
Definition: RssImage.cs:89
string Description
Contains text that is included in the TITLE attribute of the link formed around the image in the HTML...
Definition: RssImage.cs:118
Uri Link
The URL of the site, when the channel is rendered, the image is a link to the site....
Definition: RssImage.cs:102
RssImage(XmlElement Xml, Uri BaseUri)
Specifies a GIF, JPEG or PNG image that can be displayed with the channel.
Definition: RssImage.cs:17
Contains a warning message.
Definition: RssWarning.cs:9