ProjectCleaner.Parsing.ProjectParser.ParseProject C# (CSharp) Method

ParseProject() public method

public ParseProject ( ) : bool
return bool
        public bool ParseProject()
        {
            RootElement = ProjectRootElement.Open(ProjectFile);
            if (RootElement == null) return false;

            DirectoryPath = RootElement.DirectoryPath;
            Imports = RootElement.Imports;
            
            /*

            ReadItemLists(root);

            var defaultGroup = root.PropertyGroups.FirstOrDefault(x => string.IsNullOrEmpty(x.Condition));
            if (defaultGroup != null) ReadProperties(defaultGroup.Properties.ToList());

            ReadPropertyGroups(root);
            */
            return true;
        }

Usage Example

Ejemplo n.º 1
0
        public void Run(string directoryName)
        {
            //var removeFiles = new List<string>();

            var projectFiles = ProjectCollector.CollectFiles(directoryName);
            foreach (var projectFile in projectFiles)
            {
                var changed = false;
                var project = new ProjectParser(projectFile);
                if (!project.ParseProject()) continue;

                _eventAggregator.GetEvent<ProjectVisitedEvent>().Publish(projectFile);

                foreach (var processor in ProjectProcessors.Where(x=>x.IsEnabled).OrderBy(x=>x.Priority))
                {
                    changed = changed | processor.Handle(project);
                }

                if (changed)
                {
                    var tmpFileName = projectFile + ".tmp";
                    var tmpFileInfo = new FileInfo(tmpFileName);
                    if(tmpFileInfo.Exists) tmpFileInfo.IsReadOnly = false;
                    if(File.Exists(tmpFileName)) File.Delete(tmpFileName);

                    File.Copy(projectFile, tmpFileName);
                    
                    project.RootElement.Save(projectFile);

                    //removeFiles.Add(tmpFileName);
                }
            }

            //foreach (var file in removeFiles) File.Delete(file);
        }