Esempio n. 1
0
        public static IBuildFileElement Create(XmlElement xe, BuildFile bf)
        {
            if (xe == null)
            {
                return(null);
            }

            IBuildFileElement element = null;

            if (xe.Name == "BuildComponent")
            {
                element = new BuildComponent(xe, bf);
            }
            else if (xe.Name == "Property")
            {
                element = new Property(xe.Attributes["name"].Value, xe.InnerText);
                element.ParentBuildFile = bf;
            }
            else             // assume that element is a BaseAction
            {
                element = ActionFactory.Create(xe);
                element.ParentBuildFile = bf;
            }

            return(element);
        }
Esempio n. 2
0
 public void ExecuteElement(IBuildFileElement element)
 {
     if (element is IAction)
     {
         ExecuteAction((IAction)element);
     }
     else if (element is BuildComponent)
     {
         ExecuteBuildComponent((BuildComponent)element);
     }
 }
Esempio n. 3
0
 public void ExecuteElement(IBuildFileElement element)
 {
     if (element is IAction)
     {
         ExecuteAction((IAction)element);
     }
     else if (element is BuildComponent)
     {
         ExecuteBuildComponent((BuildComponent)element);
     }
 }
Esempio n. 4
0
        public static ICollection <IBuildFileElement> Parse(XmlDocument xd, BuildFile parentBuildFile)
        {
            List <IBuildFileElement> elements = new List <IBuildFileElement>();

            foreach (XmlElement xe in xd.DocumentElement.ChildNodes)
            {
                IBuildFileElement element = BuildFileElementFactory.Create(xe, parentBuildFile);

                if (element != null)
                {
                    elements.Add(element);
                }
            }

            return(elements);
        }
        public void Create()
        {
            XmlDocument xd = TestData.XmlDocument;
            BuildFile   bf = new BuildFile();

            bf.LoadXmlDocument(xd);

            IBuildFileElement elementAction = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/WriteConsole"), bf);

            Assert.IsTrue(elementAction.GetType().Name == "WriteConsole");
            Assert.AreEqual(elementAction.ParentBuildFile, bf);

            IBuildFileElement elementBuildComponent = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/BuildComponent[@name='TestComponent']"), bf);

            Assert.IsTrue(elementBuildComponent is BuildComponent);
            Assert.AreEqual("TestComponent", ((BuildComponent)elementBuildComponent).Name);
            Assert.AreEqual(elementBuildComponent.ParentBuildFile, bf);

            IBuildFileElement elementProperty = BuildFileElementFactory.Create((XmlElement)xd.GetElementsByTagName("Property")[0], bf);

            Assert.AreEqual("Property", elementProperty.GetType().Name);
            Assert.AreEqual("OutputDir", elementProperty.GetType().GetProperty("Name").GetValue(elementProperty, null).ToString());
            Assert.AreEqual(elementProperty.ParentBuildFile, bf);
        }