No support for namespaces, no intention of eventual serialization. Everything is case-insensitive, but preserves case. Not thread safe.
More...
|
| Node (string localName) |
|
| Node (XmlElement e, IIssueReceiver ir) |
| Builds a tree of Nodes from the specified XML subtree. Duplicate attributes are sent to 'ir' More...
|
|
IList< Node > | childrenByName (string elementName) |
| Returns the subset of Children with a matching element name. (Case-insensitive) More...
|
|
string | queryAttr (string selector) |
| Queryies the subtree for the specified attribute on the specified element. Example selector: element.element.attrname Assumes that the last segment of the selector is an attribute name. Throws an ArgumentException if there is only one segment ( element ). Uses the cache. More...
|
|
string | queryAttr (string nodeSelector, string attrName) |
|
Node | queryFirst (string selector) |
|
void | setAttr (string selector, string attrValue) |
| Sets the specified attribute value, creating parent elements if needed. Clears the query cache. More...
|
|
void | setAttr (string nodeSelector, string attrName, string attrValue) |
| Sets the specified attribute value, creating parent elements if needed. Clears the query cache. More...
|
|
Node | makeNodeTree (string selector) |
| Traverses the specified path, creating any missing elements along the way. Uses existing nodes if found. More...
|
|
ICollection< Node > | query (string selector) |
| Same as query(), except results are cached until clearQueryCache() is called. Faster, but can be incorrect if existing nodes are renamed, moved, or deleted. More...
|
|
void | clearQueryCache () |
|
ICollection< Node > | queryUncached (string selector) |
|
Node | deepCopy () |
| Makes a recusive copy of the subtree, keeping no duplicate references to mutable types. More...
|
|
XmlElement | ToXmlElement () |
|
XmlElement | ToXmlElement (XmlDocument doc) |
|
override string | ToString () |
|
|
KeyValuePair< string, string > | parseAttributeName (string selector) |
|
|
Dictionary< string,
ICollection< Node > > | _cachedResults = new Dictionary<string, ICollection<Node>>(StringComparer.OrdinalIgnoreCase) |
|
No support for namespaces, no intention of eventual serialization. Everything is case-insensitive, but preserves case. Not thread safe.
Definition at line 15 of file Node.cs.
ImageResizer.Configuration.Xml.Node.Node |
( |
XmlElement |
e, |
|
|
IIssueReceiver |
ir |
|
) |
| |
|
inline |
Builds a tree of Nodes from the specified XML subtree. Duplicate attributes are sent to 'ir'
- Parameters
-
Definition at line 24 of file Node.cs.
27 foreach (XmlAttribute a
in e.Attributes) {
28 if (attrs[a.LocalName] != null){
29 ir.AcceptIssue(
new Issue(
"Two or more attributes named " + a.LocalName +
" found on element " + name +
" in "
30 + e.ParentNode != null ? e.ParentNode.Name :
"(unknown node)"));
32 attrs[a.LocalName] = a.Value;
35 if (e.HasChildNodes) {
36 StringBuilder sb = null;
37 foreach (XmlNode n
in e.ChildNodes) {
38 if (n.NodeType == XmlNodeType.Element) {
39 XmlElement child = n as XmlElement;
40 if (child != null) children.Add(
new Node(child, ir));
42 }
else if (n.NodeType == XmlNodeType.Text || n.NodeType == XmlNodeType.EntityReference || n.NodeType == XmlNodeType.SignificantWhitespace) {
43 if (sb == null) sb =
new StringBuilder();
string TextContents
The concatenated text, significant whitespace, and entity references within this element. Not XML compliant for sure.
IList<Node> ImageResizer.Configuration.Xml.Node.childrenByName |
( |
string |
elementName | ) |
|
|
inline |
Returns the subset of Children with a matching element name. (Case-insensitive)
- Parameters
-
- Returns
Definition at line 102 of file Node.cs.
103 List<Node> results =
new List<Node>();
104 if (children == null || children.Count == 0)
return results;
105 foreach(Node n
in children)
106 if (n.Name.Equals(elementName, StringComparison.OrdinalIgnoreCase)) results.Add(n);
Node ImageResizer.Configuration.Xml.Node.deepCopy |
( |
| ) |
|
|
inline |
Makes a recusive copy of the subtree, keeping no duplicate references to mutable types.
- Returns
Definition at line 244 of file Node.cs.
245 Node n =
new Node(this.name);
247 foreach (
string key
in this.
Attrs.Keys) {
252 if (this.children != null)
254 n.Children.Add(c.deepCopy());
256 n.TextContents = this.TextContents;
NameValueCollection Attrs
Attributes
List< Node > Children
Child nodes
Node ImageResizer.Configuration.Xml.Node.makeNodeTree |
( |
string |
selector | ) |
|
|
inline |
Traverses the specified path, creating any missing elements along the way. Uses existing nodes if found.
- Parameters
-
- Returns
Definition at line 171 of file Node.cs.
173 Selector s =
new Selector(selector);
174 foreach (
string part
in s) {
175 IList<Node> results = n.childrenByName(part);
177 if (results == null || results.Count == 0) {
178 Node newNode =
new Node(part);
179 if (n.children == null) n.children =
new List<Node>();
180 n.Children.Add(newNode);
ICollection<Node> ImageResizer.Configuration.Xml.Node.query |
( |
string |
selector | ) |
|
|
inline |
Same as query(), except results are cached until clearQueryCache() is called. Faster, but can be incorrect if existing nodes are renamed, moved, or deleted.
- Parameters
-
- Returns
Definition at line 196 of file Node.cs.
198 if (_cachedResults.ContainsKey(selector))
return _cachedResults[selector];
200 IList<Node> uncachedResults = queryUncached(selector) as IList<Node>;
202 ICollection<Node> results = _cachedResults[selector] = uncachedResults != null ? new ReadOnlyCollection<Node>(uncachedResults) : null;
string ImageResizer.Configuration.Xml.Node.queryAttr |
( |
string |
selector | ) |
|
|
inline |
Queryies the subtree for the specified attribute on the specified element. Example selector: element.element.attrname Assumes that the last segment of the selector is an attribute name. Throws an ArgumentException if there is only one segment ( element ). Uses the cache.
- Parameters
-
- Returns
Definition at line 119 of file Node.cs.
120 KeyValuePair<string, string> parsed = parseAttributeName(selector);
121 return queryAttr(parsed.Key, parsed.Value);
string queryAttr(string selector)
Queryies the subtree for the specified attribute on the specified element. Example selector: element...
void ImageResizer.Configuration.Xml.Node.setAttr |
( |
string |
selector, |
|
|
string |
attrValue |
|
) |
| |
|
inline |
Sets the specified attribute value, creating parent elements if needed. Clears the query cache.
- Parameters
-
Definition at line 149 of file Node.cs.
151 KeyValuePair<string, string> parsed = parseAttributeName(selector);
152 setAttr(parsed.Key, parsed.Value, attrValue);
void setAttr(string selector, string attrValue)
Sets the specified attribute value, creating parent elements if needed. Clears the query cache...
void ImageResizer.Configuration.Xml.Node.setAttr |
( |
string |
nodeSelector, |
|
|
string |
attrName, |
|
|
string |
attrValue |
|
) |
| |
|
inline |
Sets the specified attribute value, creating parent elements if needed. Clears the query cache.
- Parameters
-
nodeSelector | |
attrName | |
attrValue | |
Definition at line 160 of file Node.cs.
161 Node n = queryFirst(nodeSelector);
163 n.Attrs[attrName] = attrValue;
164 this.clearQueryCache();
Node makeNodeTree(string selector)
Traverses the specified path, creating any missing elements along the way. Uses existing nodes if fou...
NameValueCollection ImageResizer.Configuration.Xml.Node.Attrs |
|
getset |
List<Node> ImageResizer.Configuration.Xml.Node.Children |
|
getset |
bool ImageResizer.Configuration.Xml.Node.IsEmpty |
|
get |
Returns true if the element has neither attributes nor children.
Definition at line 264 of file Node.cs.
string ImageResizer.Configuration.Xml.Node.Name |
|
getset |
string ImageResizer.Configuration.Xml.Node.TextContents |
|
getset |
The concatenated text, significant whitespace, and entity references within this element. Not XML compliant for sure.
Definition at line 77 of file Node.cs.
string ImageResizer.Configuration.Xml.Node.this[string name] |
|
getset |
Access attributes by name
- Parameters
-
- Returns
Definition at line 65 of file Node.cs.
The documentation for this class was generated from the following file:
- C:/Users/nathanael/Documents/resizer/Core/Configuration/Xml/Node.cs