Example #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);
        }
        public override bool Handle(ProjectParser project)
        {
            var fileInfo = new FileInfo(project.ProjectFile);
            if (fileInfo.IsReadOnly) fileInfo.IsReadOnly = false;

            var newFileName = fileInfo.FullName + ".bak";
            
            if (!File.Exists(newFileName)) fileInfo.CopyTo(newFileName);

            return false;
        }
        public override bool Handle(ProjectParser project)
        {
            var changed = false;

            var root = project.RootElement;
            foreach (var import in project.Imports)
            {
                var importName = import.Project.ToLower();
                if (!IsRemoveableTarget(importName, import.Project)) continue;
                root.RemoveChild(import);
                changed = true;
            }

            return changed;
        }
Example #4
0
 public abstract bool Handle(ProjectParser project);