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); }
bool IGlowVisitor <object, bool> .Visit(GlowParameter glow, object state) { var local = (from elem in _children where elem.Number == glow.Number select elem) .FirstOrDefault(); var xml = BuildXml(glow); if (local == null) { local = new Element(this, glow.Number, glow.Identifier, ElementType.Parameter, xml); _children.Add(local); } else { local.Update(glow.Identifier, ElementType.Parameter, xml); } var value = glow.Value; if (value != null) { local.ParameterType = value.Type; } return(true); }
GlowParameter ConvertParameter(XElement xml) { var glow = new GlowParameter(XmlConvert.ToInt32(xml.Attribute("number").Value)); FillParameter(glow, xml); return(glow); }
object IGlowVisitor <XmlWriter, object> .Visit(GlowParameter glow, XmlWriter state) { state.WriteStartElement("Parameter"); state.WriteAttributeString("number", XmlConvert.ToString(glow.Number)); ConvertParameter(glow, state); state.WriteEndElement(); return(null); }
bool IGlowVisitor <object, bool> .Visit(GlowParameter glow, object state) { if (_onParameter != null) { _onParameter(glow); return(true); } return(false); }
/// <summary> /// Creates an ember/glow tree which can be used to issue /// a parameter value change to the remote host. /// </summary> /// <returns>The GlowContainer object that is the root of /// a glow tree that mirrors the element tree up this element, /// having a GlowParameter object as the single leaf.</returns> public GlowContainer SetParameterValue(GlowValue value) { if (Type != ElementType.Parameter) { throw new InvalidOperationException(); } var glow = new GlowParameter(Number) { Value = value, }; // this builds a QualifiedNode or QualifiedParameter return(BuildQualified(Parent, glow)); // this builds a complete glow tree using the Node and // Parameter types (more verbose). //return BuildGlowTree(Parent, glow); }
public IEnumerable <GlowContainer> Visit(GlowParameter glow, object state) { throw new NotImplementedException(); }
public GlowContainer Visit(GlowParameter glow, object state) { return(WrapWithEndPointNode(glow)); }
GlowParameter ConvertParameter(XElement xml) { var glow = new GlowParameter(XmlConvert.ToInt32(xml.Attribute("number").Value)); FillParameter(glow, xml); return glow; }