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


C# ProjectInstance.ToDictionary方法代码示例

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


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

示例1: sortByBuildOrder

			static ProjectInstance[] sortByBuildOrder(ProjectInstance[] instances)
			{
				var rootProjects = instances.ToDictionary(getProjectGuid);

				var ordered = 
					rootProjects.Keys.SortTopologicallyReverse(
						g1 => getDependentProjectGuids(rootProjects[g1]).Where(rootProjects.ContainsKey));

				return ordered.Select(g => rootProjects[g]).ToArray();
			}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:10,代码来源:BackgroundBuild2.cs

示例2: projectInstancesOfPaths

		static ProjectInstance[] projectInstancesOfPaths(ProjectInstance[] allInstances, IEnumerable<string> paths)
		{
			var dictByPath = allInstances.ToDictionary(instance => instance.FullPath.ToLowerInvariant());
			return paths.Select(path => dictByPath[path.ToLowerInvariant()]).ToArray();
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:5,代码来源:BackgroundBuild2.cs

示例3: createDependentMap

		static Dictionary<Guid, HashSet<Guid>> createDependentMap(ProjectInstance[] allInstances)
		{
			var allGuids = allInstances.ToDictionary(getProjectGuid);
			var dict = new Dictionary<Guid, HashSet<Guid>>();
			foreach (var inst in allInstances)
			{
				var guid = getProjectGuid(inst);
				var deps = getDependentProjectGuids(inst).Where(allGuids.ContainsKey).ToArray();
				foreach (var dep in deps)
				{
					HashSet<Guid> dependents = null;
					if (!dict.TryGetValue(dep, out dependents))
					{
						dependents = new HashSet<Guid>();
						dict.Add(dep, dependents);
					}
					dependents.Add(guid);
				}
			}
			return dict;
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:21,代码来源:BackgroundBuild2.cs

示例4: createDependencyMap

		static Dictionary<Guid, Guid[]> createDependencyMap(ProjectInstance[] allInstances)
		{
			var allGuids = allInstances.ToDictionary(getProjectGuid);
			var dict = new Dictionary<Guid, Guid[]>();
			foreach (var inst in allInstances)
			{
				var guid = getProjectGuid(inst);
				var deps = getDependentProjectGuids(inst).Where(allGuids.ContainsKey).ToArray();
				dict.Add(guid, deps);
			}
			return dict;
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:12,代码来源:BackgroundBuild2.cs

示例5: getAffectedProjects

		/// Returns all the affected projects of the given list of projects. 
		/// Since the roots may refer to each other, the roots are included in the result set.
		static ProjectInstance[] getAffectedProjects(ProjectInstance[] allInstances, ProjectInstance[] roots)
		{
			var dependentMap = createDependentMap(allInstances);
			var allGuids = allInstances.ToDictionary(getProjectGuid);
			var rootGuids = roots.Select(getProjectGuid).ToArray();
			var todo = new Queue<Guid>(rootGuids);
			var affected = new HashSet<Guid>(rootGuids);

			while (todo.Count != 0)
			{
				var next = todo.Dequeue();

				HashSet<Guid> dependents = null;
				if (!dependentMap.TryGetValue(next, out dependents))
					continue;

				dependents.ForEach(dep => {
					if (affected.Add(dep))
						todo.Enqueue(dep); }
				);
			}

			return affected.Select(g => allGuids[g]).ToArray();
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:26,代码来源:BackgroundBuild2.cs

示例6: getDependencies

		/// Returns all the dependencies of a number of projects.
		static ProjectInstance[] getDependencies(ProjectInstance[] allInstances, ProjectInstance[] roots)
		{
			var allGuids = allInstances.ToDictionary(getProjectGuid);
			var todo = new Queue<Guid>(roots.Select(getProjectGuid));
			var rootSet = new HashSet<Guid>(roots.Select(getProjectGuid));
			var dependencies = new HashSet<Guid>();
			while (todo.Count != 0)
			{
				var next = todo.Dequeue();

				getDependentProjectGuids(allGuids[next])
					.Where(g => !dependencies.Contains(g) && !rootSet.Contains(g) && allGuids.ContainsKey(g))
					.ForEach(g =>
					{
						todo.Enqueue(g);
						dependencies.Add(g);
					});
			}

			return dependencies.Select(g => allGuids[g]).ToArray();
		}
开发者ID:pragmatrix,项目名称:BuildOnSave,代码行数:22,代码来源:BackgroundBuild2.cs


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