void Walk(GlowElementCollectionBase elements, Action <GlowParameterBase> onParameter, Action <GlowMatrixBase> onMatrix) { foreach (var element in elements) { if (element is GlowParameterBase) { if (onParameter != null) { onParameter((GlowParameterBase)element); } } else if (element is GlowMatrixBase) { if (onMatrix != null) { onMatrix((GlowMatrixBase)element); } } else if (element is GlowNodeBase) { var children = ((GlowNodeBase)element).Children; if (children != null) { Walk(children, onParameter, onMatrix); } } } }
void FillElementCollection(GlowElementCollectionBase glow, XElement xml) { var glowElements = from xmlChild in xml.Elements() let glowElement = Convert(xmlChild) as GlowElement where glowElement != null select glowElement; foreach (var glowElement in glowElements) { glow.Insert(glowElement); } }
void CreateGlowNode(Item item, int[] path, int?number, int fields, GlowElementCollectionBase parent) { if (number != null) { path = path.Concat(new[] { number.Value }).ToArray(); } var glow = new GlowQualifiedNode(path); if ((fields & GlowFieldFlags.Identifier) != 0) { glow.Identifier = item.Identifier; } if ((fields & GlowFieldFlags.Description) != 0 && String.IsNullOrEmpty(item.Name) == false) { glow.Description = item.Name; } parent.Insert(glow); }
void CreateGlowParameter(Item item, int[] path, int?number, int fields, GlowElementCollectionBase parent) { var glowValue = null as GlowValue; var isWriteable = false; if ((fields & GlowFieldFlags.Value) != 0) { var valueKind = item.Parent.Key.GetValueKind(item.Name); var value = item.Parent.Key.GetValue(item.Name); switch (valueKind) { case RegistryValueKind.Binary: glowValue = new GlowValue((byte[])value); break; case RegistryValueKind.DWord: glowValue = new GlowValue((long)(int)value); isWriteable = true; break; case RegistryValueKind.ExpandString: glowValue = new GlowValue((string)value); break; case RegistryValueKind.MultiString: glowValue = new GlowValue(String.Join("\n", (string[])value)); break; case RegistryValueKind.QWord: glowValue = new GlowValue((long)value); isWriteable = true; break; case RegistryValueKind.String: glowValue = new GlowValue((string)value); isWriteable = true; break; } } if (number != null) { path = path.Concat(new[] { number.Value }).ToArray(); } var glow = new GlowQualifiedParameter(path); if ((fields & GlowFieldFlags.Identifier) != 0) { glow.Identifier = item.Identifier; } if ((fields & GlowFieldFlags.Description) != 0 && String.IsNullOrEmpty(item.Name) == false) { glow.Description = item.Name; } if (fields == GlowFieldFlags.All && isWriteable) { glow.Access = GlowAccess.ReadWrite; } if (glowValue != null) { glow.Value = glowValue; } parent.Insert(glow); }
void FillElementCollection(GlowElementCollectionBase glow, XElement xml) { var glowElements = from xmlChild in xml.Elements() let glowElement = Convert(xmlChild) as GlowElement where glowElement != null select glowElement; foreach(var glowElement in glowElements) glow.Insert(glowElement); }