private void Execute(AsyncTask.Context context) { Log.WriteLine("GetSolutionFiles STARTED"); List <string> solution_files = new List <string>(); List <string> projects = new List <string>(); try { foreach (Project project in this.m_DTE.Solution.Projects) { this.GetFilesRecursive(project, context, solution_files, projects); if (context.Cancelled) { break; } } if (context.Cancelled) { Log.WriteLine("GetSolutionFiles cancelled"); } } catch (Exception arg_7E_0) { Utils.LogExceptionQuiet(arg_7E_0); } if (!context.Cancelled) { Log.WriteLine("GetSolutionFiles FINISHED"); if (this.FinishedCallback != null) { this.FinishedCallback(solution_files, projects); } } }
private void ThreadMain() { while (!this.m_Exiting) { object @lock = this.m_Lock; int start_time; lock (@lock) { start_time = this.m_StartTime; AsyncTask.Context task_context = this.m_TaskContext; goto IL_82; } goto IL_32; IL_82: if ((start_time != 0 && start_time <= Environment.TickCount) || this.m_Exiting) { // AsyncTask.Context task_context; AsyncTask.Context task_context = this.m_TaskContext;//mariotodo if (!this.m_Exiting && task_context != null) { if (this.m_DTETask) { using (new MessageFilter()) { this.m_TaskFunction(task_context); goto IL_D9; } goto IL_CD; } goto IL_CD; IL_D9: @lock = this.m_Lock; lock (@lock) { if (!task_context.Cancelled) { this.m_TaskContext = null; this.m_StartTime = 0; } } continue; IL_CD: this.m_TaskFunction(task_context); goto IL_D9; } continue; } IL_32: int sleep_time = (start_time != 0) ? Math.Max(0, start_time - Environment.TickCount) : -1; this.m_WakeEvent.WaitOne(sleep_time); @lock = this.m_Lock; lock (@lock) { start_time = this.m_StartTime; AsyncTask.Context task_context = this.m_TaskContext; } goto IL_82; } }
private void Execute(AsyncTask.Context context) { ProfileTimer timer = new ProfileTimer("GetOpenFilesEvent"); Set <string> ext_to_scan = (Set <string>)context.Arg; List <string> m_OpenFiles = new List <string>(); List <UnsavedDocument> m_UnsavedDocuments = new List <UnsavedDocument>(); List <Document> documents = new List <Document>(); ProfileTimer get_documents_timer = new ProfileTimer("GetDocuments"); try { foreach (Document document in this.m_DTE.Documents) { documents.Add(document); } } catch (Exception arg_83_0) { Utils.LogExceptionQuiet(arg_83_0); } get_documents_timer.Stop(); foreach (Document document2 in documents) { try { string fullname = document2.FullName; string ext = Path.GetExtension(fullname).ToLower(); if (ext_to_scan.Contains(ext)) { m_OpenFiles.Add(fullname); if (!document2.Saved) { m_UnsavedDocuments.Add(new UnsavedDocument(document2)); } } } catch (Exception arg_E6_0) { Utils.LogExceptionQuiet(arg_E6_0); } if (context.Cancelled) { break; } } timer.Stop(); if (!context.Cancelled && this.Finished != null) { this.Finished(m_OpenFiles, m_UnsavedDocuments); } }
public void Cancel() { object @lock = this.m_Lock; lock (@lock) { if (this.m_TaskContext != null) { this.m_TaskContext.Cancel(); this.m_TaskContext = null; this.m_StartTime = 0; } } }
public void Start(AsyncTask.Context task_context, int delay) { int start_time = Environment.TickCount + delay; object @lock = this.m_Lock; lock (@lock) { bool already_started = false; if (this.m_TaskContext != null) { this.m_TaskContext.Cancel(); already_started = true; } this.m_TaskContext = task_context; if (!already_started || start_time > this.m_StartTime) { this.m_StartTime = start_time; } this.m_WakeEvent.Set(); } }
private void ExecuteTask(AsyncTask.Context context) { Log.WriteLine("FildFinder.ExecuteTask started"); FileFinder.Job job = (FileFinder.Job)context.Arg; List <FindFileResult> found_files; if (job.m_TextBoxValue == "") { found_files = new List <FindFileResult>(); } else if (job.m_IsEnteringPath) { found_files = this.FindFilesInPath(job, context); } else { found_files = this.FindFilesInSolution(job, context); } Log.WriteLine("FildFinder.ExecuteTask finished"); job.m_FinishedHandler(found_files, job.m_TextBoxValue); }
private void GetFilesRecursive(Project project, AsyncTask.Context context, List <string> solution_files, List <string> projects) { ///mariotodo if (context.Cancelled) { return; } string project_kind = project.Kind.ToLower(); ProjectItems project_items = project.ProjectItems; if (project_kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}".ToLower()) { if (project_items == null) { return; } { IEnumerator enumerator = project_items.GetEnumerator(); while (enumerator.MoveNext()) { Project sub_project = ((ProjectItem)enumerator.Current).SubProject; if (sub_project != null) { this.GetFilesRecursive(sub_project, context, solution_files, projects); } if (context.Cancelled) { break; } } return; } } try { if (project_kind != "{66A2671D-8FB5-11D2-AA7E-00C04F688DDE}".ToLower()) { string project_full_name = project.FullName; if (!string.IsNullOrEmpty(project_full_name)) { projects.Add(project_full_name); } } } catch (Exception arg_B9_0) { Utils.LogExceptionQuiet(arg_B9_0); } try { if (project_items != null) { foreach (ProjectItem project_item in project_items) { this.GetProjectFilesRecursive(project_item, context, solution_files, projects); if (context.Cancelled) { break; } } } } catch (Exception arg_10E_0) { Utils.LogExceptionQuiet(arg_10E_0); } }
private void GetProjectFilesRecursive(ProjectItem project_item, AsyncTask.Context context, List <string> solution_files, List <string> projects) { if (project_item == null || project_item.GetType().ToString().Contains("OAReferenceItem")) { return; } try { string kind = ""; try { kind = project_item.Kind.ToLower(); } catch (Exception arg_30_0) { Utils.LogExceptionQuiet(arg_30_0); } if (kind == "{6BB5F8EE-4483-11D3-8BCF-00C04F8EC28C}".ToLower() || kind == "{66A2671F-8FB5-11D2-AA7E-00C04F688DDE}".ToLower()) { int file_count = (int)project_item.FileCount; short i = 1; while ((int)i <= file_count) { try { string filename = project_item.get_FileNames(i); if (!string.IsNullOrEmpty(filename) && Path.GetExtension(filename).ToLower() != ".dll") { solution_files.Add(filename); } } catch (Exception arg_9B_0) { Utils.LogExceptionQuiet(arg_9B_0); } if (context.Cancelled) { break; } i += 1; } } ProjectItems sub_project_items = null; try { sub_project_items = project_item.ProjectItems; } catch (Exception arg_CE_0) { Log.WriteLine("WARNING: Project item doesn't have ProjectItems: Kind: " + kind); Utils.LogExceptionQuiet(arg_CE_0); } if (sub_project_items != null) { foreach (ProjectItem sub_project_item in sub_project_items) { this.GetProjectFilesRecursive(sub_project_item, context, solution_files, projects); } } } catch (Exception arg_11E_0) { Utils.LogExceptionQuiet(arg_11E_0); } }
private void WriteTask(AsyncTask.Context context) { this.WriteInternal(); }
public void Start(AsyncTask.Context task_context) { this.Start(task_context, 0); }
private List <FindFileResult> FindFilesInSolution(FileFinder.Job job, AsyncTask.Context context) { FileFinder.SolutionFiles solution_files = null; object @lock = this.m_Lock; lock (@lock) { solution_files = this.m_SolutionFiles; } string pattern = job.m_TextBoxValue; if (!this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal)) { pattern = pattern.ToLower(); } SettingsDialogPage arg_5D_0 = VSAnythingPackage.Inst.GetSettingsDialogPage(); bool match_case = job.m_MatchCase; if (arg_5D_0.SpacesAsWildcardsForFindFile && pattern.Contains(' ')) { pattern = "*" + pattern.Replace(' ', '*') + "*"; } bool use_wildacrd = job.m_UseWildcards && pattern.Contains('*'); if (use_wildacrd) { if (!pattern.StartsWith("*")) { pattern = "*" + pattern; } if (!pattern.EndsWith("*")) { pattern += "*"; } } bool use_full_paths = pattern.Contains("\\"); IEnumerable <string> arg_121_0 = this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal) ? (use_full_paths ? solution_files.m_SolutionFilePaths : solution_files.m_SolutionFileNames) : (use_full_paths ? solution_files.m_SolutionFilePathsLowerCase : solution_files.m_SolutionFileNamesLowercase); List <FindFileResult> found_files = new List <FindFileResult>(); int i = 0; foreach (string file in arg_121_0) { bool match; if (use_wildacrd) { match = Wildcard.Match(file, pattern); } else if (match_case) { match = file.Contains(pattern); } else { match = Utils.StrStr(file, pattern); } if (match) { string file_path = solution_files.m_SolutionFilePaths[i]; string file_name = solution_files.m_SolutionFileNames[i]; FindFileResult found_file = default(FindFileResult); found_file.m_FilePath = file_path; found_file.m_FileName = file_name; if (Path.IsPathRooted(job.m_RootPath) && Path.IsPathRooted(file_path) && Path.GetPathRoot(job.m_RootPath) == Path.GetPathRoot(file_path) && !Utils.IsSolutionFile(file_path)) { found_file.m_RelativeFilePath = Misc.GetRelativePath(job.m_RootPath, file_path); } else { found_file.m_RelativeFilePath = file_path; } found_file.m_PathMatch = false; found_files.Add(found_file); } i++; if (context.Cancelled) { break; } } return(found_files); }
private List <FindFileResult> FindFilesInPath(FileFinder.Job job, AsyncTask.Context context) { List <FindFileResult> found_files = new List <FindFileResult>(); string path = job.m_TextBoxValue; string dir; try { dir = Path.GetDirectoryName(path); } catch (Exception arg_16_0) { Log.WriteLine(arg_16_0.Message); dir = path; } if (!Directory.Exists(dir)) { dir = Path.GetDirectoryName(dir); } if (!Directory.Exists(dir)) { return(found_files); } List <string> items = new List <string>(); if (!context.Cancelled) { string[] array = Directory.GetDirectories(dir); for (int i = 0; i < array.Length; i++) { string child_dir = array[i]; items.Add(Path.GetFileName(child_dir)); if (context.Cancelled) { break; } } } if (!context.Cancelled) { string[] array = Directory.GetFiles(dir); for (int i = 0; i < array.Length; i++) { string file = array[i]; items.Add(Path.GetFileName(file)); if (context.Cancelled) { break; } } } string pattern = Path.GetFileName(path).Trim().ToLower(); if (!string.IsNullOrEmpty(pattern)) { bool use_wildcard = job.m_UseWildcards && pattern.Contains('*'); List <string> filtered_items = new List <string>(); foreach (string item in items) { bool match; if (use_wildcard) { match = Wildcard.Match(item.ToLower(), pattern); } else { match = Utils.StrStr(item.ToLower(), pattern); } if (match) { filtered_items.Add(item); } if (context.Cancelled) { break; } } items = filtered_items; } if (!context.Cancelled) { foreach (string item2 in items) { found_files.Add(new FindFileResult { m_FileName = item2, m_PathMatch = true }); } } return(found_files); }