/// <summary> /// Creates and initializes the configuration options. /// </summary> /// <param name="parent">Parent configuration node, the root configuration.</param> /// <param name="configContext">Not used.</param> /// <param name="configNode">The configuration node.</param> /// <returns>A <c>RunnerSection</c> object.</returns> public object Create(object parent, object configContext, XmlNode configNode) { if (configNode == null) { return(null); } RunnerSection runner = new RunnerSection(); XmlNodeList nodes = configNode.SelectNodes("customizations/customization[not(boolean(@enabled)) or @enabled=\"true\"]"); try { ProcessCustomizations(nodes, runner.Customizations); nodes = configNode.SelectNodes("sources"); RunnerSource sch; foreach (XmlNode node in nodes) { sch = new RunnerSource(node.Attributes["file"].Value); ProcessCustomizations(node.SelectNodes("customizations/customization[not(boolean(@enabled)) or @enabled=\"true\"]"), sch.Customizations); runner.Sources.Add(sch.FileName, sch); } } catch (Exception ex) { throw new ConfigurationException("Invalid values found in Runner configuration.", ex); } return(runner); }
/// <summary> /// <c>ICloneable</c> implementation. Returns a shallow copy of the object. /// </summary> public object Clone() { RunnerSection sec = new RunnerSection(); sec.Customizations = Customizations.Clone() as SortedList; foreach (RunnerSource sch in Sources) { sec.Sources.Add(sch.FileName, sch.Clone()); } return(sec); }
/// <summary> /// Merges an existing RunnerSection object with the new data. /// </summary> public object Merge(object currentConfig, object parent, object configContext, XmlNode configNode) { RunnerSection runner = currentConfig as RunnerSection; RunnerSection merger; if (runner != null) { merger = runner.Clone() as RunnerSection; } else { merger = new RunnerSection(); } if (runner == null && configNode == null) { return(null); } if (configNode == null) { return(merger); } XmlNodeList nodes = configNode.SelectNodes("customizations/customization[not(boolean(@enabled)) or @enabled=\"true\"]"); try { ProcessCustomizations(nodes, merger.Customizations); nodes = configNode.SelectNodes("sources/source"); RunnerSource sch; foreach (XmlNode node in nodes) { sch = new RunnerSource(node.Attributes["file"].Value); ProcessCustomizations(node.SelectNodes("customizations/customization[not(boolean(@enabled)) or @enabled=\"true\"]"), sch.Customizations); merger.Sources.Add(sch.FileName, sch); } } catch (Exception ex) { throw new ConfigurationException("Invalid values found in Runner configuration.", ex); } return(merger); }