public Node(TreeNode Parent, NodeInformation NodeInfo) : base(Parent) { this.nodeInfo = NodeInfo; if (this.nodeInfo.ParameterList == null) { this.parameters = null; } else { this.parameters = new DisplayableParameters(this.nodeInfo.ParameterList); } if (nodeInfo.HasChildren) { this.children = new SortedDictionary <string, TreeNode>() { { string.Empty, new Loading(this) } }; } }
public PubSubNode(TreeNode Parent, string Jid, string Node, string Name, NodeType NodeType) : base(Parent) { this.jid = Jid; this.node = Node; this.name = Name; this.nodeType = NodeType; List <Parameter> Parameters = new List <Parameter>(); if (!string.IsNullOrEmpty(this.jid)) { Parameters.Add(new StringParameter("JID", "JID", this.jid)); } if (!string.IsNullOrEmpty(this.name)) { Parameters.Add(new StringParameter("Name", "Name", this.name)); } if (this.nodeType == NodeType.collection) { Parameters.Add(new StringParameter("Type", "Type", "Collection")); } else { Parameters.Add(new StringParameter("Type", "Type", "Leaf")); } this.children = new SortedDictionary <string, TreeNode>() { { string.Empty, new Loading(this) } }; this.parameters = new DisplayableParameters(Parameters.ToArray()); }
public PubSubItem(TreeNode Parent, string Jid, string Node, string ItemId, string Payload, string Publisher) : base(Parent) { XmlElement E; this.jid = Jid; this.node = Node; this.itemId = ItemId; this.payload = Payload; this.publisher = Publisher; this.xml = new XmlDocument(); try { this.xml.LoadXml(Payload); if (this.xml != null && (E = this.xml.DocumentElement) != null) { if (E.LocalName == "entry" && E.NamespaceURI == "http://www.w3.org/2005/Atom") { foreach (XmlNode N in E.ChildNodes) { if (N is XmlElement E2) { switch (E2.LocalName.ToLower()) { case "title": this.title = E2.InnerText; break; case "summary": this.summary = E2.InnerText; break; case "published": if (XML.TryParse(E2.InnerText, out DateTime TP)) { this.published = TP; } break; case "link": this.link = XML.Attribute(E2, "href"); break; } } } } } } catch (Exception) { this.xml = null; // Not XML payload. } List <Parameter> Parameters = new List <Parameter>(); if (!string.IsNullOrEmpty(this.jid)) { Parameters.Add(new StringParameter("JID", "JID", this.jid)); } if (!string.IsNullOrEmpty(this.node)) { Parameters.Add(new StringParameter("Node", "Node", this.node)); } if (!string.IsNullOrEmpty(this.publisher)) { Parameters.Add(new StringParameter("Publisher", "Publisher", this.publisher)); } if (!string.IsNullOrEmpty(this.title)) { Parameters.Add(new StringParameter("Title", "Title", this.title)); } if (published != null) { Parameters.Add(new DateTimeParameter("Published", "Published", this.published.Value)); } this.parameters = new DisplayableParameters(Parameters.ToArray()); }