Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HtmlAttribute.cs
1using System.Collections.Generic;
2using System.Text;
3using System.Xml;
4
5namespace Waher.Content.Html
6{
10 public class HtmlAttribute : HtmlNode
11 {
12 private LinkedList<HtmlNode> segments = null;
13 private readonly string name;
14 private string @value;
15
26 int EndPosition, string Name, string Value)
28 {
29 this.name = Name;
30 this.@value = Value;
31 this.segments = null;
32 }
33
43 int EndPosition, string Name)
45 {
46 this.name = Name;
47 this.@value = null;
48 this.segments = null;
49 }
50
61 {
62 this.name = Name;
63 this.@value = Value;
64 this.segments = null;
65 }
66
76 {
77 this.name = Name;
78 this.@value = null;
79 this.segments = null;
80 }
81
85 public string Name => this.name;
86
87 internal void Add(HtmlNode Segment)
88 {
89 if (this.segments is null)
90 this.segments = new LinkedList<HtmlNode>();
91
92 this.segments.AddLast(Segment);
93 this.@value = null;
94 }
95
96 internal bool HasSegments
97 {
98 get { return !(this.segments is null); }
99 }
100
104 public string Value
105 {
106 get
107 {
108 if (this.@value is null)
109 {
110 if (!(this.segments is null))
111 {
112 StringBuilder sb = new StringBuilder();
113
114 foreach (HtmlNode N in this.segments)
115 sb.Append(N.ToString());
116
117 this.@value = sb.ToString();
118 }
119 else
120 this.@value = string.Empty;
121 }
122
123 return this.@value;
124 }
125
126 internal set
127 {
128 this.@value = value;
129 this.segments = null;
130 }
131 }
132
134 public override string ToString()
135 {
136 return this.name + "=" + this.Value;
137 }
138
143 public override void Export(XmlWriter Output)
144 {
145 int i = this.name.IndexOf(':');
146 if (i < 0)
147 Output.WriteAttributeString(this.name, this.@value);
148 else
149 {
150 Output.WriteAttributeString(this.name.Substring(0, i),
151 this.name.Substring(i + 1), string.Empty, this.@value);
152 }
153 }
154
159 public override void Export(StringBuilder Output)
160 {
161 Output.Append(' ');
162 Output.Append(this.name);
163 Output.Append("=\"");
164 Output.Append(Xml.XML.Encode(this.@value));
165 Output.Append('"');
166 }
167 }
168}
string Name
Attribute name.
HtmlAttribute(HtmlDocument Document, HtmlElement Parent, int StartPosition, int EndPosition, string Name, string Value)
HTML attribute
HtmlAttribute(HtmlDocument Document, HtmlElement Parent, int StartPosition, string Name)
HTML attribute
override void Export(XmlWriter Output)
Exports the HTML document to XML.
HtmlAttribute(HtmlDocument Document, HtmlElement Parent, int StartPosition, string Name, string Value)
HTML attribute
string Value
Attribute value.
override void Export(StringBuilder Output)
Exports the HTML document to XML.
HtmlAttribute(HtmlDocument Document, HtmlElement Parent, int StartPosition, int EndPosition, string Name)
HTML attribute
Base class for all HTML elements.
Definition: HtmlElement.cs:12
Base class for all HTML nodes.
Definition: HtmlNode.cs:11
int StartPosition
Start position of element.
Definition: HtmlNode.cs:60
HtmlDocument Document
HTML Document
Definition: HtmlNode.cs:49
HtmlNode Parent
Parent node, if available.
Definition: HtmlNode.cs:54
int EndPosition
End position of element.
Definition: HtmlNode.cs:69