Esempio n. 1
0
 public Section(Section original)
     : this(original.Name, original.SectionType, original.Step, original.PropertyLines)
 {
 }
Esempio n. 2
0
        public static Project FromElement(string projectGuid, NodeElement element, Dictionary <string, string> solutionFolderGuids)
        {
            string projectTypeGuid     = null;
            string projectName         = null;
            string relativePath        = null;
            string parentFolderGuid    = null;
            var    projectSections     = new List <Section>();
            var    versionControlLines = new List <PropertyLine>();
            var    projectConfigurationPlatformsLines = new List <PropertyLine>();

            foreach (var child in element.Childs)
            {
                var identifier = child.Identifier;
                if (identifier.Name == TagProjectTypeGuid)
                {
                    projectTypeGuid = ((ValueElement)child).Value;
                }
                else if (identifier.Name == TagProjectName)
                {
                    projectName = ((ValueElement)child).Value;
                }
                else if (identifier.Name == TagRelativePath)
                {
                    relativePath = ((ValueElement)child).Value;
                }
                else if (identifier.Name == TagParentFolder)
                {
                    var parentProjectFullName = ((ValueElement)child).Value;
                    if (!solutionFolderGuids.ContainsKey(parentProjectFullName))
                    {
                        throw new Exception("TODO");
                    }

                    parentFolderGuid = solutionFolderGuids[parentProjectFullName];
                }
                else if (identifier.Name.StartsWith(TagProjectSection))
                {
                    var sectionName = identifier.Name.Substring(TagProjectSection.Length);
                    projectSections.Add(
                        Section.FromElement(
                            sectionName,
                            (NodeElement)child));
                }
                else if (identifier.Name.StartsWith(TagVersionControlLines))
                {
                    var name  = identifier.Name.Substring(TagVersionControlLines.Length);
                    var value = ((ValueElement)child).Value;
                    versionControlLines.Add(new PropertyLine(name, value));
                }
                else if (identifier.Name.StartsWith(TagProjectConfigurationPlatformsLines))
                {
                    var name  = identifier.Name.Substring(TagProjectConfigurationPlatformsLines.Length);
                    var value = ((ValueElement)child).Value;
                    projectConfigurationPlatformsLines.Add(new PropertyLine(name, value));
                }
                else
                {
                    throw new SolutionFileException(string.Format("Invalid identifier '{0}'.", identifier.Name));
                }
            }

            if (projectTypeGuid == null)
            {
                throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectTypeGuid));
            }
            if (projectName == null)
            {
                throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectName));
            }
            if (relativePath == null)
            {
                throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagRelativePath));
            }

            return(new Project(
                       null,
                       projectGuid,
                       projectTypeGuid,
                       projectName,
                       relativePath,
                       parentFolderGuid,
                       projectSections,
                       versionControlLines,
                       projectConfigurationPlatformsLines));
        }
Esempio n. 3
0
 private void WriteSection(Section section, IEnumerable<PropertyLine> propertyLines)
 {
     m_writer.WriteLine("\t{0}({1}) = {2}", section.SectionType, section.Name, section.Step);
     foreach (var propertyLine in propertyLines)
     {
         m_writer.WriteLine("\t\t{0} = {1}", propertyLine.Name, propertyLine.Value);
     }
     m_writer.WriteLine("\tEnd{0}", section.SectionType);
 }
Esempio n. 4
0
 public Section(Section original)
     : this(original.Name, original.SectionType, original.Step, original.PropertyLines)
 {
 }