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


C# Solution.LoadPreferences方法代码示例

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


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

示例1: ReadSolution

		public void ReadSolution(Solution solution, IProgressMonitor progress)
		{
			ReadFormatHeader();
			ReadVersionProperties(solution);
			
			// Read solution folder and project entries:
			var solutionEntries = new List<ProjectLoadInformation>();
			var projectInfoDict = new Dictionary<Guid, ProjectLoadInformation>();
			var solutionFolderDict = new Dictionary<Guid, SolutionFolder>();
			int projectCount = 0;
			bool fixedGuidConflicts = false;
			
			ProjectLoadInformation information;
			while ((information = ReadProjectEntry(solution)) != null) {
				solutionEntries.Add(information);
				if (projectInfoDict.ContainsKey(information.IdGuid)) {
					// resolve GUID conflicts
					SD.Log.WarnFormatted("Detected duplicate GUID in .sln file: {0} is used for {1} and {2}", information.IdGuid, information.ProjectName, projectInfoDict[information.IdGuid].ProjectName);
					information.IdGuid = Guid.NewGuid();
					fixedGuidConflicts = true;
				}
				projectInfoDict.Add(information.IdGuid, information);
				
				if (information.TypeGuid == ProjectTypeGuids.SolutionFolder) {
					solutionFolderDict.Add(information.IdGuid, CreateSolutionFolder(solution, information));
				} else {
					projectCount++;
				}
			}
			
			progress.CancellationToken.ThrowIfCancellationRequested();
			
			// Read global sections:
			if (currentLine != "Global") {
				if (currentLine == null)
					throw Error("Unexpected end of file");
				else
					throw Error("Unknown line: " + currentLine);
			}
			NextLine();
			
			Dictionary<Guid, SolutionFolder> guidToParentFolderDict = null;
			
			SolutionSection section;
			while ((section = ReadSection(isGlobal: true)) != null) {
				switch (section.SectionName) {
					case "SolutionConfigurationPlatforms":
						var configurations = LoadSolutionConfigurations(section);
						foreach (var config in configurations.Select(c => c.Configuration).Distinct(ConfigurationAndPlatform.ConfigurationNameComparer))
							solution.ConfigurationNames.Add(config, null);
						foreach (var platform in configurations.Select(c => c.Platform).Distinct(ConfigurationAndPlatform.ConfigurationNameComparer))
							solution.PlatformNames.Add(platform, null);
						break;
					case "ProjectConfigurationPlatforms":
						LoadProjectConfigurations(section, projectInfoDict);
						break;
					case "NestedProjects":
						guidToParentFolderDict = LoadNesting(section, solutionFolderDict);
						break;
					default:
						solution.GlobalSections.Add(section);
						break;
				}
			}
			if (currentLine != "EndGlobal")
				throw Error("Expected 'EndGlobal'");
			NextLine();
			if (currentLine != null)
				throw Error("Expected end of file");
			
			solution.LoadPreferences();
			
			// Now that the project configurations have been set, we can actually load the projects:
			int projectsLoaded = 0;
			foreach (var projectInfo in solutionEntries) {
				// Make copy of IdGuid just in case the project binding writes to projectInfo.IdGuid
				Guid idGuid = projectInfo.IdGuid;
				ISolutionItem solutionItem;
				if (projectInfo.TypeGuid == ProjectTypeGuids.SolutionFolder) {
					solutionItem = solutionFolderDict[idGuid];
				} else {
					// Load project:
					projectInfo.ActiveProjectConfiguration = projectInfo.ConfigurationMapping.GetProjectConfiguration(solution.ActiveConfiguration);
					progress.TaskName = "Loading " + projectInfo.ProjectName;
					using (projectInfo.ProgressMonitor = progress.CreateSubTask(1.0 / projectCount)) {
						solutionItem = LoadProjectWithErrorHandling(projectInfo);
					}
					if (solutionItem.IdGuid != idGuid) {
						Guid projectFileGuid = solutionItem.IdGuid;
						if (!projectInfoDict.ContainsKey(projectFileGuid)) {
							// We'll use the GUID from the project file.
							// Register that GUID in the dictionary to avoid its use by multiple projects.
							projectInfoDict.Add(projectFileGuid, projectInfo);
						} else {
							// Cannot use GUID from project file due to conflict.
							// To fix the problem without potentially introducing new conflicts in other .sln files that contain the project,
							// we generate a brand new GUID:
							solutionItem.IdGuid = Guid.NewGuid();
						}
						SD.Log.WarnFormatted("<ProjectGuid> in project '{0}' is '{1}' and does not match the GUID stored in the solution ({2}). "
//.........这里部分代码省略.........
开发者ID:ratoy,项目名称:SharpDevelop,代码行数:101,代码来源:SolutionLoader.cs

示例2: CreateEmptySolutionFile

		public ISolution CreateEmptySolutionFile(FileName fileName)
		{
			if (fileName == null)
				throw new ArgumentNullException("fileName");
			if (fileName.IsRelative)
				throw new ArgumentException("Path must be rooted!");
			Solution solution = new Solution(fileName, new ProjectChangeWatcher(fileName), SD.FileService);
			solution.LoadPreferences();
			return solution;
		}
开发者ID:RHE24,项目名称:SharpDevelop,代码行数:10,代码来源:ProjectService.cs

示例3: ReadSolution

		public void ReadSolution(Solution solution, IProgressMonitor progress)
		{
			ReadFormatHeader();
			ReadVersionProperties(solution);
			
			// Read solution folder and project entries:
			var solutionEntries = new List<ProjectLoadInformation>();
			var projectInfoDict = new Dictionary<Guid, ProjectLoadInformation>();
			var solutionFolderDict = new Dictionary<Guid, SolutionFolder>();
			int projectCount = 0;
			bool fixedGuidConflicts = false;
			
			ProjectLoadInformation information;
			while ((information = ReadProjectEntry(solution)) != null) {
				solutionEntries.Add(information);
				if (projectInfoDict.ContainsKey(information.IdGuid)) {
					// resolve GUID conflicts
					information.IdGuid = Guid.NewGuid();
					fixedGuidConflicts = true;
				}
				projectInfoDict.Add(information.IdGuid, information);
				
				if (information.TypeGuid == ProjectTypeGuids.SolutionFolder) {
					solutionFolderDict.Add(information.IdGuid, CreateSolutionFolder(solution, information));
				} else {
					projectCount++;
				}
			}
			
			progress.CancellationToken.ThrowIfCancellationRequested();
			
			// Read global sections:
			if (currentLine != "Global") {
				if (currentLine == null)
					throw Error("Unexpected end of file");
				else
					throw Error("Unknown line: " + currentLine);
			}
			NextLine();
			
			Dictionary<Guid, SolutionFolder> guidToParentFolderDict = null;
			
			SolutionSection section;
			while ((section = ReadSection(isGlobal: true)) != null) {
				switch (section.SectionName) {
					case "SolutionConfigurationPlatforms":
						var configurations = LoadSolutionConfigurations(section);
						foreach (var config in configurations.Select(c => c.Configuration).Distinct(ConfigurationAndPlatform.ConfigurationNameComparer))
							solution.ConfigurationNames.Add(config, null);
						foreach (var platform in configurations.Select(c => c.Platform).Distinct(ConfigurationAndPlatform.ConfigurationNameComparer))
							solution.PlatformNames.Add(platform, null);
						break;
					case "ProjectConfigurationPlatforms":
						LoadProjectConfigurations(section, projectInfoDict);
						break;
					case "NestedProjects":
						guidToParentFolderDict = LoadNesting(section, solutionFolderDict);
						break;
					default:
						solution.GlobalSections.Add(section);
						break;
				}
			}
			if (currentLine != "EndGlobal")
				throw Error("Expected 'EndGlobal'");
			NextLine();
			if (currentLine != null)
				throw Error("Expected end of file");
			
			solution.LoadPreferences();
			
			// Now that the project configurations have been set, we can actually load the projects:
			int projectsLoaded = 0;
			foreach (var projectInfo in solutionEntries) {
				ISolutionItem solutionItem;
				if (projectInfo.TypeGuid == ProjectTypeGuids.SolutionFolder) {
					solutionItem = solutionFolderDict[projectInfo.IdGuid];
				} else {
					// Load project:
					projectInfo.ActiveProjectConfiguration = projectInfo.ConfigurationMapping.GetProjectConfiguration(solution.ActiveConfiguration);
					progress.TaskName = "Loading " + projectInfo.ProjectName;
					using (projectInfo.ProgressMonitor = progress.CreateSubTask(1.0 / projectCount)) {
						solutionItem = ProjectBindingService.LoadProject(projectInfo);
					}
					projectsLoaded++;
					progress.Progress = (double)projectsLoaded / projectCount;
				}
				// Add solutionItem to solution:
				SolutionFolder folder;
				if (guidToParentFolderDict != null && guidToParentFolderDict.TryGetValue(projectInfo.IdGuid, out folder)) {
					folder.Items.Add(solutionItem);
				} else {
					solution.Items.Add(solutionItem);
				}
			}
			
			solution.IsDirty = fixedGuidConflicts; // reset IsDirty=false unless we've fixed GUID conflicts
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:98,代码来源:SolutionLoader.cs


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