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


C# WorkspaceItem.GetAllProjects方法代码示例

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


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

示例1: Add

		public void Add (WorkspaceItem item)
		{
			foreach (Project project in item.GetAllProjects ()) {
				Add (project);
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:6,代码来源:CodeMetricsWidget.cs

示例2: StartAnalysis

		public void StartAnalysis (WorkspaceItem solution)
		{
			lock (_lock) {
				tokenSource = new CancellationTokenSource ();
				processedFiles = new ConcurrentDictionary<string, object> ();
				ThreadPool.QueueUserWorkItem (delegate {
					State = AnalysisState.Running;

					using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor ("Analyzing solution", null, false)) {
						AnalysisState oldState;
						AnalysisState newState;
						try {
							int work = 0;
							foreach (var project in solution.GetAllProjects ()) {
								work += project.Files.Count (f => f.BuildAction == BuildAction.Compile);
							}
							monitor.BeginTask ("Analyzing solution", work);
							foreach (var project in solution.GetAllProjects ()) {
								if (tokenSource.IsCancellationRequested)
									break;
								var content = TypeSystemService.GetProjectContext (project);
								Parallel.ForEach (project.Files, file => {
									try {
										AnalyzeFile (file, content);
										monitor.Step (1);
									} catch (Exception ex) {
										LoggingService.LogError ("Error while running code issue on:" + file.Name, ex);
									}
								});
							}
							// Cleanup
							lock (_lock) {
								oldState = state;
								if (tokenSource.IsCancellationRequested) {
									newState = AnalysisState.Cancelled;
								} else {
									newState = AnalysisState.Completed;
								}
								state = newState;
								tokenSource = null;
							}
							OnAnalysisStateChanged (new AnalysisStateChangeEventArgs (oldState, newState));
						} catch (Exception e) {
							lock (_lock) {
								oldState = state;
								state = AnalysisState.Error;
								newState = state;
								tokenSource = null;
							}
							OnAnalysisStateChanged (new AnalysisStateChangeEventArgs (oldState, newState));
							// Do not rethrow in a thread pool
							MessageService.ShowException (e);
						}
					}
				});
			}
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:57,代码来源:CodeAnalysisBatchRunner.cs

示例3: StartAnalysis

		public void StartAnalysis (WorkspaceItem solution)
		{
			lock (_lock) {
				tokenSource = new CancellationTokenSource ();
				ThreadPool.QueueUserWorkItem (delegate {
					State = AnalysisState.Running;

					using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor ("Analyzing solution", null, false)) {
						int work = 0;
						foreach (var project in solution.GetAllProjects ()) {
							work += project.Files.Count (f => f.BuildAction == BuildAction.Compile);
						}
						monitor.BeginTask ("Analyzing solution", work);
						var processedFiles = new ConcurrentDictionary<string, object> ();
						foreach (var project in solution.GetAllProjects ()) {
							if (tokenSource.IsCancellationRequested)
								break;
							var content = TypeSystemService.GetProjectContext (project);
							Parallel.ForEach (project.Files, file => {
								var me = new object();
								var owner = processedFiles.AddOrUpdate(file.Name, me, (key, old) => old);
								if (me != owner)
									return;
								if (file.BuildAction != BuildAction.Compile || tokenSource.IsCancellationRequested)
									return;

								var editor = TextFileProvider.Instance.GetReadOnlyTextEditorData (file.FilePath);
								var document = TypeSystemService.ParseFile (project, editor);
								if (document == null) 
									return;

								var compilation  = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation ();
								var resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile);
								var context = document.CreateRefactoringContextWithEditor (editor, resolver, tokenSource.Token);

								CodeIssueProvider[] codeIssueProvider = RefactoringService.GetInspectors (editor.MimeType).ToArray ();
								Parallel.ForEach (codeIssueProvider, (provider) => { 
									var severity = provider.GetSeverity ();
									if (severity == Severity.None || tokenSource.IsCancellationRequested)
										return;
									try {
										foreach (var issue in provider.GetIssues (context, tokenSource.Token)) {
											AddIssue (file, provider, issue);
										}
									} catch (OperationCanceledException) {
										// The operation was cancelled, no-op as the user-visible parts are
										// handled elsewhere
									} catch (Exception ex) {
										LoggingService.LogError ("Error while running code issue on:" + editor.FileName, ex);
									}
								});
								//lastMime = editor.MimeType;
								monitor.Step (1);
							});
						}
						// Cleanup
						AnalysisState oldState;
						AnalysisState newState;
						lock (_lock) {
							oldState = state;
							if (tokenSource.IsCancellationRequested) {
								newState = AnalysisState.Cancelled;
							} else {
								newState = AnalysisState.Completed;
							}
							state = newState;
							tokenSource = null;
						}
						OnAnalysisStateChanged(new AnalysisStateChangeEventArgs(oldState, newState));
						monitor.EndTask ();
					}
				});
			}
		}
开发者ID:ncoder83,项目名称:monodevelop,代码行数:74,代码来源:CodeAnalysisBatchRunner.cs


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