bool IGlowVisitor <object, bool> .Visit(GlowNode glow, object state) { var local = (from elem in _children where elem.Number == glow.Number select elem) .FirstOrDefault(); var isComplete = glow.Identifier != null; var xml = isComplete ? BuildXml(glow) : null; if (local == null) { local = new Element(this, glow.Number, glow.Identifier, ElementType.Node, xml); _children.Add(local); } else { local.Update(glow.Identifier, ElementType.Node, xml); } var children = glow.Children; if (children != null) { isComplete |= children.Accept(local, null); } return(isComplete); }
GlowNode ConvertNode(XElement xml) { var glow = new GlowNode(XmlConvert.ToInt32(xml.Attribute("number").Value)); FillNode(glow, xml); return(glow); }
static GlowRootElementCollection BuildGlowTree(Element local, GlowElement glow) { while (local.Type != ElementType.Root) { GlowElement glowParent; if (local.Type == ElementType.Parameter) { var param = new GlowParameter(local.Number); param.Children = new GlowElementCollection(GlowTags.Parameter.Children); param.Children.Insert(glow); glowParent = param; } else { var node = new GlowNode(local.Number); node.Children = new GlowElementCollection(GlowTags.Node.Children); node.Children.Insert(glow); glowParent = node; } glow = glowParent; local = local.Parent; } var root = GlowRootElementCollection.CreateRoot(); root.Insert(glow); return(root); }
object IGlowVisitor <XmlWriter, object> .Visit(GlowNode glow, XmlWriter state) { state.WriteStartElement("Node"); state.WriteAttributeString("number", XmlConvert.ToString(glow.Number)); ConvertNode(glow, state); state.WriteEndElement(); return(null); }
GlowContainer WrapWithEndPointNode(GlowContainer glow) { var newNode = new GlowNode(EndPointNumber); var children = new GlowElementCollection(GlowTags.Node.Children); children.Insert(glow); newNode.Children = children; return(newNode); }
bool IGlowVisitor <object, bool> .Visit(GlowNode glow, object state) { if (_onNode != null) { _onNode(glow); return(true); } return(false); }
void EndPoint_StateChanged(object sender, EventArgs e) { var glow = GlowRootElementCollection.CreateRoot(); var ep = (Consumer.GlowEndPoint)sender; var glowNode = new GlowNode(ep.LocalNumber) { Identifier = ep.HostName + ":" + ep.TcpPort, IsOnline = ep.State == Consumer.GlowEndPointState.Connected, }; glow.Insert(glowNode); OnGlowFromProviderReady(new GlowFromProviderReadyArgs(glow)); }
// - handle Node, stripping outer node (turn Node.Children into GlowRootElementCollection) public IEnumerable <GlowContainer> Visit(GlowNode glow, object state) { EndPointNumber = glow.Number; var children = glow.Children; if (children != null) { foreach (var child in children.Elements) { yield return(child); } } }
public GlowContainer Visit(GlowNode glow, object state) { return(WrapWithEndPointNode(glow)); }
GlowNode ConvertNode(XElement xml) { var glow = new GlowNode(XmlConvert.ToInt32(xml.Attribute("number").Value)); FillNode(glow, xml); return glow; }