Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <c>ICloneable</c> implementation. Returns a shallow copy of the object.
        /// </summary>
        public RunnerSource Clone()
        {
            RunnerSource sch = new RunnerSource();

            sch._customizations = Customizations.Clone() as SortedList;
            sch._filename       = _filename;
            return(sch);
        }
Ejemplo n.º 3
0
        /// <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);
        }