Parse() публичный Метод

public Parse ( System.Xml.Linq.XElement element, BuildProject buildProject ) : Target
element System.Xml.Linq.XElement
buildProject FluentBuild.BuildFileConverter.Structure.BuildProject
Результат FluentBuild.BuildFileConverter.Structure.Target
Пример #1
0
        public void ShouldParseDependsSeperatedByCommas()
        {
            var targetXml            = XElement.Parse("<target name=\"basic\" depends=\"clean compile\"><call target=\"mainbuild\"/></target>");
            var target               = _subject.Parse(targetXml, null);
            var mockDependancyTarget = MockRepository.GenerateStub <ITarget>();

            _targetRepository.Stub(x => x.Resolve("clean")).Return(mockDependancyTarget);
            _targetRepository.Stub(x => x.Resolve("compile")).Return(mockDependancyTarget);
            Assert.That(target.DependsOn.Count, Is.EqualTo(2));
            _targetRepository.AssertWasCalled(x => x.Register(target));
        }
        public BuildProject ParseDocument(XDocument document)
        {
            var buildProject = new BuildProject();
            var parser       = new TargetParser();

            var projectNode = document.Root; //get the project node

            if (projectNode == null)
            {
                throw new ApplicationException("Could not open root node");
            }

            if (projectNode.Attribute("default") != null)
            {
                buildProject.DefaultTarget = projectNode.Attribute("default").Value;
            }

            foreach (var childNode in projectNode.Elements("property"))
            {
                var property = new Property(childNode.Attribute("name").Value, childNode.Attribute("value").Value);
                buildProject.AddProperty(property);
            }

            foreach (var childNode in projectNode.Elements("target"))
            {
                buildProject.Targets.Add(parser.Parse(childNode, buildProject));
                //childNode.Attribute("name").Value.Replace(".", "_"), childNode.ToString());
            }

            IEnumerable <XElement> unkownElements = from XElement unkownElement in projectNode.Elements()
                                                    where
                                                    unkownElement.Name != "target" &&
                                                    unkownElement.Name != "property"
                                                    select unkownElement;

            foreach (XElement unkownElement in unkownElements)
            {
                buildProject.Unkown.Add(unkownElement.Name.ToString(), unkownElement.ToString());
            }
            return(buildProject);
        }
Пример #3
0
        public BuildProject ParseDocument(XDocument document)
        {
            var buildProject = new BuildProject();
            var parser = new TargetParser();

            var projectNode = document.Root; //get the project node
            if (projectNode == null)
                throw new ApplicationException("Could not open root node");

            if (projectNode.Attribute("default") != null)
                buildProject.DefaultTarget = projectNode.Attribute("default").Value;

            foreach (var childNode in projectNode.Elements("property"))
            {
                var property = new Property(childNode.Attribute("name").Value, childNode.Attribute("value").Value);
                buildProject.AddProperty(property);
            }

            foreach (var childNode in projectNode.Elements("target"))
            {
                buildProject.Targets.Add(parser.Parse(childNode, buildProject));
                //childNode.Attribute("name").Value.Replace(".", "_"), childNode.ToString());
            }

            IEnumerable<XElement> unkownElements = from XElement unkownElement in projectNode.Elements()
                                                   where
                                                       unkownElement.Name != "target" &&
                                                       unkownElement.Name != "property"
                                                   select unkownElement;

            foreach (XElement unkownElement in unkownElements)
            {
                buildProject.Unkown.Add(unkownElement.Name.ToString(), unkownElement.ToString());
            }
            return buildProject;
        }