本文整理汇总了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);
}
}
示例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);
}
}
});
}
}
示例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 ();
}
});
}
}