public void LoadFromXML(XmlNode resourceNode) { XMLResourceTypeFactory.LoadFromXML(resourceNode, this); /// if the display color is specified, then load it, /// otherwise use a random color if (resourceNode.Attributes["display_color"] != null) { this._displayColor = System.Drawing.Color.FromName(resourceNode.Attributes["display_color"].Value); } else { Random random = Controller.Random; this._displayColor = System.Drawing.Color.FromArgb(random.Next(256), random.Next(256), random.Next(256), random.Next(256)); } XMLResourceTypeFactory.CreateResourceTypeFields(this.SubTypes, resourceNode); foreach (System.Xml.XmlNode node in resourceNode.ChildNodes) { switch (node.Name) { case "execute": Scripts.Script executionType = XMLScriptFactory.CreateScript(node); this.Executions.Add(executionType.Name, executionType); break; default: continue; } } }
public static Scripts.Script CreateScript(XmlNode node) { System.Diagnostics.Debug.Assert(node.Name == "execute"); string name = node.Attributes["name"].Value; string help = node.Attributes["help"].Value; Scripts.Script script = new Scripts.Script(name, help); foreach (XmlNode stepNode in node.ChildNodes) { script.Steps.Add(CreateStep(stepNode)); } return(script); }
public static Scripts.Script CreateScript(XmlNode node) { System.Diagnostics.Debug.Assert(node.Name == "execute"); string name = node.Attributes["name"].Value; string help = node.Attributes["help"].Value; Scripts.Script script = new Scripts.Script(name, help); foreach (XmlNode stepNode in node.ChildNodes) { script.Steps.Add (CreateStep (stepNode)); } return script; }