本文介绍了在Visual Studio 2017 C#中自动执行搜索命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从解决方案"中搜索一长串短语.因此,有没有一种方法可以自动执行此搜索,而不是使用Ctr + Shift + F命令手动执行此操作?由于发现的大多数内容都是编写代码以从文件中进行搜索,所以我想使用Visual Studio在其解决方案中进行搜索.谢谢!!

I need to search for a long list of phrases from a Solution. So instead of using the Ctr+Shift+F command to do it manually, is there a way to automate this search? As most I found was writing codes to search from a file, I want to use visual studio to search within its Solution. Thank you!!

推荐答案

您可以使用 DTE.Find 对象设置搜索选项并调用搜索.使用我的 Visual Commander 扩展名,它看起来像:

You can use DTE.Find object to set search options and invoke search. With my Visual Commander extension it looks like:

public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
    DTE.Find.FindWhat = @"Test";
    DTE.Find.Target = EnvDTE.vsFindTarget.vsFindTargetSolution;

    DTE.Find.Action = EnvDTE.vsFindAction.vsFindActionFindAll;
    DTE.Find.Backwards = false;
    DTE.Find.FilesOfType = @"";
    DTE.Find.KeepModifiedDocumentsOpen = false;
    DTE.Find.MatchCase = false;
    DTE.Find.MatchInHiddenText = true;
    DTE.Find.MatchWholeWord = false;
    DTE.Find.PatternSyntax = EnvDTE.vsFindPatternSyntax.vsFindPatternSyntaxLiteral;
    DTE.Find.ReplaceWith = @"";
    DTE.Find.ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1;
    DTE.Find.SearchSubfolders = true;
    DTE.Find.SearchPath = @"Entire Solution";
    DTE.Find.Execute();
}

这篇关于在Visual Studio 2017 C#中自动执行搜索命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 10:34