public void Remove(Project project) { XDocument xml = XDocument.Load(Filename); GetNodeById(xml, project).Remove(); xml.Save(Filename); }
public void Update(Project project) { XDocument xml = XDocument.Load(Filename); XElement exisitingProject = GetNodeById(xml, project); exisitingProject.RemoveAll(); SerializeProject(project, exisitingProject); xml.Save(Filename); }
public ProcessingState(Project project) { Project = project; IsProcessingInProgress = false; Log = new StringBuilder(); FileSystemWatcher = new FileSystemWatcher { Filter = "*.scss" }; UpdateWatcher(); Files = new List<FileModel>(); }
private static void SerializeProject(Project project, XElement projectElement) { XmlSerializer serializer = new XmlSerializer(project.GetType()); using (StringWriter stream = new StringWriter()) { serializer.Serialize(stream, project); XDocument serializedProject = XDocument.Parse(stream.ToString()); foreach (XElement projectProperty in serializedProject.Root.Elements()) { projectElement.Add(projectProperty); } } }
private void Submit(object sender, EventArgs e) { if (!ValidateChildren()) { DialogResult = DialogResult.None; return; } Project = Project ?? new Project { Id = Guid.NewGuid() }; Project.Name = nameTextBox.Text; Project.SourceFolderPath = sourceFolderTextBox.Text; Project.DestinationFolderPath = destinationFolderTextBox.Text; Project.IncludeSubdirectories = includeSubdirectoriesCheckBox.Checked; }
public void Add(Project project) { XDocument xml = XDocument.Load(Filename); XElement exisitingProject = GetNodeById(xml, project); if (exisitingProject == null) { XElement projectElement = new XElement("Project"); SerializeProject(project, projectElement); xml.Root.Add(projectElement); xml.Save(Filename); } }
private void Log(Project project, string message) { project.ProcessingState.Log.AppendFormat("[{0}] {1}{2}", DateTime.Now.ToLongTimeString(), message, Environment.NewLine); UpdateLog(); }
private void UpdateStartStopButtons(Project project) { Bitmap image; string menuItemText, toolbarButtonTooltip; if (project.ProcessingState.IsProcessingInProgress) { image = Resources.Stop; menuItemText = "Stop"; toolbarButtonTooltip = "Stop preprocessing"; } else { image = Resources.Start; menuItemText = "Start"; toolbarButtonTooltip = "Start preprocessing"; } startStopToolStripButton.Image = startStopToolStripMenuItem.Image = image; startStopToolStripMenuItem.Text = menuItemText; startStopToolStripButton.ToolTipText = toolbarButtonTooltip; }
private void CompileFile(FileModel file, Project project) { file.Dependencies.Clear(); ManagedCallbackManager.SetFileAccessCallBack(file.AddDependency); try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string output = _compiler.CompileFile(file.FullPath); // Save file into physical one if it is not mixin file if (!Path.GetFileName(file.FullPath).StartsWith("_")) { // TODO: Save file here } stopwatch.Stop(); Log(project, String.Format("Successfully compiled file at {0}, compilation took {1} ms", file.Path, stopwatch.ElapsedMilliseconds)); } catch (SassCompileException ex) { Log(project, String.Format("Error while preprocessing file at {0}:{1}{2}", file.Path, Environment.NewLine, ex.Message)); } ManagedCallbackManager.UnsetFileAccessCallBack(); }
private static XElement GetNodeById(XDocument xml, Project project) { return xml.Root.Elements().SingleOrDefault(element => element.Element("Id").Value == project.Id.ToString()); }
public FileModel(Project project) { Dependencies = new List<string>(); Project = project; LastChecksum = 0; }