public void Save() { var root = new XElement("Solution"); var projects = new XElement("Projects"); foreach (CrcsProject proj in _projects) { string relativePath = FolderUtility.GetRelativePath(SolutionPath, proj.FileSystemPath); var xitem = new XElement("Item", relativePath.Replace(Path.DirectorySeparatorChar, '\\'), new XAttribute("IncludeInBuild", proj.IncludeInBuild)); projects.Add(xitem); } foreach (string missingProj in _missingProjects) { projects.Add(new XElement("Item", missingProj, new XAttribute("MainProject", false))); } if (projects.HasElements) { root.Add(projects); } var properties = new XElement("Properties"); foreach (PropertyInfo prop in _properties.GetType().GetProperties()) { if (prop.CanRead && prop.CanWrite && prop.InProjectFile().StoreInProjectFile) { object value = prop.GetValue(_properties, null); if (value == null) { continue; } var xElement = new XElement("Item", new XAttribute("Name", prop.Name)); xElement.Value = value.ToString(); properties.Add(xElement); } } if (properties.HasElements) { root.Add(properties); } root.Save(FileSystemPath); _isDirty = false; if (TabItemControl != null) { TabItemControl.EvaluateDirty(); } }
public void Update(InfoEntityData infoEntityData) { List <ParameterData> list = new List <ParameterData>(); list.Add(new ParameterData("构件名称", infoEntityData.EntityName)); if (infoEntityData != null && infoEntityData.Data != null) { Dictionary <string, string> data = infoEntityData.Data; foreach (string key in data.Keys) { list.Add(new ParameterData(key, data[key])); } //添加备注列 list.Add(new ParameterData("备注", infoEntityData.Remark)); Dictionary <string, List <string> > groupMsg = infoEntityData.GroupMsg; ItemCollection currentItems = this.tabControl.Items; //清空items //从后向前删除 //最后一个不删 for (int i = currentItems.Count - 1; i > 0; i--) { currentItems.Remove(currentItems[i]); } foreach (string groupName in groupMsg.Keys) { TabItem item = new TabItem() { Header = groupName }; TabItemControl Itemcontent = new TabItemControl(); item.Content = Itemcontent; List <ParameterData> content_data = new List <ParameterData>(); foreach (string keyName in groupMsg[groupName]) { content_data.Add(new ParameterData(keyName, data[keyName])); } Itemcontent.Update(content_data); this.tabControl.Items.Add(item); } } elementInfoHost.Update(list); }
public override void Save() { var root = new XElement("Project"); XElement additionalDependencies = CreateAdditionalDependenciesElement(); if (additionalDependencies.HasElements) { root.Add(additionalDependencies); } var projectFiles = new XElement("ProjectFiles"); foreach (IProjectItem file in _items.Where(x => x.IsIncluded)) { string projectRelativePath = GetProjectRelativePath(file); var compositFile = file as CompositFile; if (compositFile != null && compositFile.IgnoreDecompileErrors) { projectFiles.Add(new XElement("Item", new XAttribute("Path", projectRelativePath.Replace(Path.DirectorySeparatorChar, '\\')), new XAttribute("IgnoreDecompileErrors", true))); } else { projectFiles.Add(new XElement("Item", new XAttribute("Path", projectRelativePath))); } } if (projectFiles.HasElements) { root.Add(projectFiles); } var projectProperties = new XElement("Properties"); foreach (PropertyInfo prop in _properties.GetType().GetProperties()) { if (prop.CanRead && prop.CanWrite && prop.InProjectFile().StoreInProjectFile) { object value = prop.GetValue(_properties, null); if (value == null) { continue; } var xElement = new XElement("Item", new XAttribute("Name", prop.Name)); xElement.Value = value.ToString(); projectProperties.Add(xElement); } } foreach (string frameWorkFile in _properties.FrameWorkFiles) { var xElement = new XElement("Item", new XAttribute("Name", "FrameWorkFile")) { Value = Path.GetFileName(frameWorkFile) ?? "" }; projectProperties.Add(xElement); } if (projectProperties.HasElements) { root.Add(projectProperties); } root.Save(FileSystemPath); _properties.SaveBuildProps(); _isDirty = false; if (TabItemControl != null) { TabItemControl.EvaluateDirty(); } }