Exemplo n.º 1
0
        /// <summary>
        /// Restores the former state of a pipeline from Xml.
        /// </summary>
        /// <param name="pipeline">The <see cref="XDocument"/> describing the
        /// pipeline.</param>
        /// <returns>The set of processes within the pipeline as described in
        /// the Xml.</returns>
        public Client.PipelineDefinition RestorePipeline(XDocument pipeline)
        {
            if (pipeline == null)
            {
                return(new Client.PipelineDefinition());
            }

            var factories = _repo.ToDictionary();
            PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(factories);
            DecompilationVisitor  visitor    = new DecompilationVisitor(decompiler);
            PipelineXmlValidator  validator  = new PipelineXmlValidator(visitor, factories.Keys);

            validator.ThrowOnError = true;
            XmlTraverser traverser = new XmlTraverser(validator);

            try
            {
                traverser.Traverse(pipeline);
                var algorithms = visitor.Algorithms;
                _updateAlgorithmNames(algorithms);
                return(new Client.PipelineDefinition(algorithms));
            }
            catch (Exception e)
            {
                throw new ArgumentException("Error restoring Pipeline Xml.", e);
            }
        }
Exemplo n.º 2
0
        public void TestDecompile_NotXElement()
        {
            IDictionary <string, IPipelineXmlInterpreter> factories = new Dictionary <string, IPipelineXmlInterpreter>();

            factories.Add("Test", new DudInterpreter());
            PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(factories);
            XText element = new XText("Test");

            decompiler.DecompileAlgorithm(element);
        }
Exemplo n.º 3
0
        public void TestDecompile_NoProperties()
        {
            string name = "Test";
            IDictionary <string, IPipelineXmlInterpreter> factories = new Dictionary <string, IPipelineXmlInterpreter>();

            factories.Add("Test", new DudInterpreter());
            PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(factories);
            XNode element = new XElement("process", new XAttribute("name", name));
            var   d       = decompiler.DecompileAlgorithm(element);

            Assert.AreEqual(name, d.AlgorithmName);
            Assert.IsNull(d.ParameterObject);
        }
Exemplo n.º 4
0
        public void TestDecompile_UnknownProcess()
        {
            string name = "Unknown";
            IDictionary <string, IPipelineXmlInterpreter> factories = new Dictionary <string, IPipelineXmlInterpreter>();

            factories.Add("Test", new DudInterpreter());
            PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(factories);
            XNode element = new XElement(
                "process", new XAttribute("name", name),
                new XElement("properties",
                             new XElement("property",
                                          new XAttribute("name", "test"),
                                          new XAttribute("value", "1"))));

            decompiler.DecompileAlgorithm(element);
        }
Exemplo n.º 5
0
        public void TestDecompile_WithProperty()
        {
            string name = "Test";
            IDictionary <string, IPipelineXmlInterpreter> factories = new Dictionary <string, IPipelineXmlInterpreter>();
            DudInterpreter i = new DudInterpreter();

            factories.Add("Test", i);
            PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(factories);
            XNode element = new XElement(
                "process", new XAttribute("name", name),
                new XElement("properties",
                             new XElement("property",
                                          new XAttribute("name", "test"),
                                          new XAttribute("value", "1"))));
            var d = decompiler.DecompileAlgorithm(element);

            Assert.IsNotNull(d.ParameterObject);
            Assert.IsTrue(i.DidCallCreateObject);
        }
Exemplo n.º 6
0
 public void TestConstructor_NullFactories()
 {
     PipelineXmlDecompiler decompiler = new PipelineXmlDecompiler(null);
 }