当前位置: 首页>>代码示例>>C#>>正文


C# Solution.Save方法代码示例

本文整理汇总了C#中ICSharpCode.SharpDevelop.Project.Solution.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.Save方法的具体用法?C# Solution.Save怎么用?C# Solution.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpDevelop.Project.Solution的用法示例。


在下文中一共展示了Solution.Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save

		public void Save(Solution solution)
		{
			if (WorkbenchSingleton.InvokeRequired) {
				Action<Solution> action = Save;
				WorkbenchSingleton.SafeThreadCall<Solution>(action, solution);
			} else {
				solution.Save();
			}
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:9,代码来源:PackageManagementProjectService.cs

示例2: CreateSolution

		public string CreateSolution(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
		{
			string oldSolutionPath = projectCreateInformation.SolutionPath;
			string oldProjectPath = projectCreateInformation.ProjectBasePath;
			if (relativeDirectory != null && relativeDirectory.Length > 0 && relativeDirectory != ".") {
				projectCreateInformation.SolutionPath     = Path.Combine(projectCreateInformation.SolutionPath, relativeDirectory);
				projectCreateInformation.ProjectBasePath = Path.Combine(projectCreateInformation.SolutionPath, relativeDirectory);
				if (!Directory.Exists(projectCreateInformation.SolutionPath)) {
					Directory.CreateDirectory(projectCreateInformation.SolutionPath);
				}
				if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) {
					Directory.CreateDirectory(projectCreateInformation.ProjectBasePath);
				}
			}
			
			projectCreateInformation.SolutionPath = oldSolutionPath;
			projectCreateInformation.ProjectBasePath = oldProjectPath;
			
			string newSolutionName = StringParser.Parse(name, new StringTagPair("ProjectName", projectCreateInformation.SolutionName));
			
			string solutionLocation = Path.Combine(projectCreateInformation.SolutionPath, newSolutionName + ".sln");
			
			Solution newSolution = new Solution(new ProjectChangeWatcher(solutionLocation));
			projectCreateInformation.Solution = newSolution;
			
			newSolution.Name = newSolutionName;
			
			if (!mainFolder.AddContents(newSolution, projectCreateInformation, defaultLanguage, newSolution)) {
				newSolution.Dispose();
				return null;
			}
			
			// Save solution
			if (File.Exists(solutionLocation)) {
				
				string question = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.CombineDescriptor.OverwriteProjectQuestion}",
				                                     new StringTagPair("combineLocation", solutionLocation));
				if (MessageService.AskQuestion(question)) {
					newSolution.Save(solutionLocation);
				}
			} else {
				newSolution.Save(solutionLocation);
			}
			ProjectService.OnSolutionCreated(new SolutionEventArgs(newSolution));
			newSolution.Dispose();
			return solutionLocation;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:47,代码来源:SolutionDescriptor.cs

示例3: CreateSolution

		public string CreateSolution(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
		{
			Solution newSolution = new Solution();
			projectCreateInformation.Solution = newSolution;
			
			string newCombineName = StringParser.Parse(name, new string[,] {
			                                           	{"ProjectName", projectCreateInformation.ProjectName}
			                                           });
			
			newSolution.Name = newCombineName;
			
			string oldCombinePath = projectCreateInformation.SolutionPath;
			string oldProjectPath = projectCreateInformation.ProjectBasePath;
			if (relativeDirectory != null && relativeDirectory.Length > 0 && relativeDirectory != ".") {
				projectCreateInformation.SolutionPath     = Path.Combine(projectCreateInformation.SolutionPath, relativeDirectory);
				projectCreateInformation.ProjectBasePath = Path.Combine(projectCreateInformation.SolutionPath, relativeDirectory);
				if (!Directory.Exists(projectCreateInformation.SolutionPath)) {
					Directory.CreateDirectory(projectCreateInformation.SolutionPath);
				}
				if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) {
					Directory.CreateDirectory(projectCreateInformation.ProjectBasePath);
				}
			}
			
			projectCreateInformation.SolutionPath = oldCombinePath;
			projectCreateInformation.ProjectBasePath = oldProjectPath;
			
			if (!mainFolder.AddContents(newSolution, projectCreateInformation, defaultLanguage, newSolution)) {
				newSolution.Dispose();
				return null;
			}
			
			string combineLocation = Path.Combine(projectCreateInformation.SolutionPath, newCombineName + ".sln");
			// Save combine
			if (File.Exists(combineLocation)) {
				
				StringParser.Properties["combineLocation"] = combineLocation;
				if (MessageService.AskQuestion("${res:ICSharpCode.SharpDevelop.Internal.Templates.CombineDescriptor.OverwriteProjectQuestion}")) {
					newSolution.Save(combineLocation);
				}
			} else {
				newSolution.Save(combineLocation);
			}
			newSolution.Dispose();
			return combineLocation;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:46,代码来源:CombineDescriptor.cs

示例4: SetupSolution

		static bool SetupSolution(Solution newSolution)
		{
			ProjectSection nestedProjectsSection = null;
			
			// read solution files using system encoding, but detect UTF8 if BOM is present
			using (StreamReader sr = new StreamReader(newSolution.FileName, Encoding.Default, true)) {
				string line = GetFirstNonCommentLine(sr);
				Match match = versionPattern.Match(line);
				if (!match.Success) {
					MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.InvalidSolutionFile}", newSolution.FileName);
					return false;
				}
				
				switch (match.Result("${Version}")) {
					case "7.00":
					case "8.00":
						MessageService.ShowError("${res:SharpDevelop.Solution.CannotLoadOldSolution}");
						return false;
					case "9.00":
					case "10.00":
					case "11.00":
					case "12.00":
						break;
					default:
						MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}"));
						return false;
				}
				
				using (AsynchronousWaitDialog waitDialog = AsynchronousWaitDialog.ShowWaitDialog("Loading solution")) {
					nestedProjectsSection = SetupSolutionLoadSolutionProjects(newSolution, sr, waitDialog);
				}
			}
			// Create solution folder 'tree'.
			if (nestedProjectsSection != null) {
				foreach (SolutionItem item in nestedProjectsSection.Items) {
					string from = item.Name;
					string to   = item.Location;
					if (newSolution.guidDictionary.ContainsKey(to) && newSolution.guidDictionary.ContainsKey(from)) {
						// ignore invalid entries
						
						ISolutionFolderContainer folder = newSolution.guidDictionary[to] as ISolutionFolderContainer;
						folder.AddFolder(newSolution.guidDictionary[from]);
					}
				}
			}
			
			if (!newSolution.ReadOnly && (newSolution.FixSolutionConfiguration(newSolution.Projects))) {
				// save in new format
				newSolution.Save();
			}
			return true;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:52,代码来源:Solution.cs

示例5: SetupSolution

		static bool SetupSolution(Solution newSolution, string fileName)
		{
			string         solutionDirectory     = Path.GetDirectoryName(fileName);
			ProjectSection nestedProjectsSection = null;
			
			bool needsConversion = false;
			
			// read solution files using system encoding, but detect UTF8 if BOM is present
			using (StreamReader sr = new StreamReader(fileName, Encoding.Default, true)) {
				string line = GetFirstNonCommentLine(sr);
				Match match = versionPattern.Match(line);
				if (!match.Success) {
					MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.InvalidSolutionFile}", fileName);
					return false;
				}
				
				switch (match.Result("${Version}")) {
					case "7.00":
						needsConversion = true;
						if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ConvertSolutionVersion7}")) {
							return false;
						}
						break;
					case "8.00":
						needsConversion = true;
						if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ConvertSolutionVersion8}")) {
							return false;
						}
						break;
					case "9.00":
						break;
					default:
						MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}"));
						return false;
				}
				
				while (true) {
					line = sr.ReadLine();
					
					if (line == null) {
						break;
					}
					match = projectLinePattern.Match(line);
					if (match.Success) {
						string projectGuid  = match.Result("${ProjectGuid}");
						string title        = match.Result("${Title}");
						string location     = match.Result("${Location}");
						string guid         = match.Result("${Guid}");
						
						if (!FileUtility.IsUrl(location)) {
							location = Path.GetFullPath(Path.Combine(solutionDirectory, location));
						}
						
						if (projectGuid == FolderGuid) {
							SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
							newSolution.AddFolder(newFolder);
						} else {
							IProject newProject = LanguageBindingService.LoadProject(newSolution, location, title, projectGuid);
							ReadProjectSections(sr, newProject.ProjectSections);
							newProject.IdGuid = guid;
							newSolution.AddFolder(newProject);
						}
						match = match.NextMatch();
					} else {
						match = globalSectionPattern.Match(line);
						if (match.Success) {
							ProjectSection newSection = ProjectSection.ReadGlobalSection(sr, match.Result("${Name}"), match.Result("${Type}"));
							// Don't put the NestedProjects section into the global sections list
							// because it's transformed to a tree representation and the tree representation
							// is transformed back to the NestedProjects section during save.
							if (newSection.Name == "NestedProjects") {
								nestedProjectsSection = newSection;
							} else {
								newSolution.Sections.Add(newSection);
							}
						}
					}
				}
			}
			// Create solution folder 'tree'.
			if (nestedProjectsSection != null) {
				foreach (SolutionItem item in nestedProjectsSection.Items) {
					string from = item.Name;
					string to   = item.Location;
					ISolutionFolderContainer folder = newSolution.guidDictionary[to] as ISolutionFolderContainer;
					folder.AddFolder(newSolution.guidDictionary[from]);
				}
			}
			
			if (newSolution.FixSolutionConfiguration(newSolution.Projects) || needsConversion) {
				// save in new format
				newSolution.Save();
			}
			return true;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:95,代码来源:Solution.cs

示例6: Load

		public static Solution Load(string fileName)
		{
			Solution newSolution = new Solution();
			solutionBeingLoaded = newSolution;
			newSolution.Name     = Path.GetFileNameWithoutExtension(fileName);
			
			string extension = Path.GetExtension(fileName).ToUpperInvariant();
			if (extension == ".CMBX") {
				if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ImportCmbx}")) {
					return null;
				}
				newSolution.fileName = Path.ChangeExtension(fileName, ".sln");
				ICSharpCode.SharpDevelop.Project.Converter.CombineToSolution.ConvertSolution(newSolution, fileName);
				if (newSolution.FixSolutionConfiguration(newSolution.Projects)) {
					newSolution.Save();
				}
			} else if (extension == ".PRJX") {
				if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ImportPrjx}")) {
					return null;
				}
				newSolution.fileName = Path.ChangeExtension(fileName, ".sln");
				ICSharpCode.SharpDevelop.Project.Converter.CombineToSolution.ConvertProject(newSolution, fileName);
				if (newSolution.FixSolutionConfiguration(newSolution.Projects)) {
					newSolution.Save();
				}
			} else {
				newSolution.fileName = fileName;
				if (!SetupSolution(newSolution, fileName)) {
					return null;
				}
			}
			
			solutionBeingLoaded = null;
			return newSolution;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:35,代码来源:Solution.cs


注:本文中的ICSharpCode.SharpDevelop.Project.Solution.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。