本文整理汇总了C#中MonoDevelop.Ide.FindInFiles.FilterOptions类的典型用法代码示例。如果您正苦于以下问题:C# FilterOptions类的具体用法?C# FilterOptions怎么用?C# FilterOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterOptions类属于MonoDevelop.Ide.FindInFiles命名空间,在下文中一共展示了FilterOptions类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetFiles
public override IEnumerable<FileProvider> GetFiles(IProgressMonitor monitor, FilterOptions filterOptions)
{
foreach (Document document in IdeApp.Workbench.Documents) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in '{0}'", document.FileName));
if (!string.IsNullOrEmpty (document.FileName) && filterOptions.NameMatches (document.FileName))
yield return new FileProvider (document.FileName);
}
}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:8,代码来源:Scope.cs
示例2: ValidatePattern
public bool ValidatePattern (FilterOptions filter, string pattern)
{
if (filter.RegexSearch) {
try {
new Regex (pattern, RegexOptions.Compiled);
return true;
} catch (Exception) {
return false;
}
}
return true;
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:12,代码来源:FindReplace.cs
示例3: FindAll
public IEnumerable<SearchResult> FindAll(Scope scope, IProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter)
{
if (filter.RegexSearch) {
RegexOptions regexOptions = RegexOptions.Compiled;
if (!filter.CaseSensitive)
regexOptions |= RegexOptions.IgnoreCase;
regex = new Regex (pattern, regexOptions);
}
IsRunning = true;
FoundMatchesCount = SearchedFilesCount = 0;
monitor.BeginTask (scope.GetDescription (filter, pattern, replacePattern), 50);
try {
int totalWork = scope.GetTotalWork (filter);
int step = Math.Max (1, totalWork / 50);
string content;
foreach (FileProvider provider in scope.GetFiles (monitor, filter)) {
if (monitor.IsCancelRequested)
yield break;
SearchedFilesCount++;
try {
content = provider.ReadString ();
if (replacePattern != null)
provider.BeginReplace (content);
} catch (System.IO.FileNotFoundException) {
Application.Invoke (delegate {
MessageService.ShowError (string.Format (GettextCatalog.GetString ("File {0} not found.")), provider.FileName);
});
continue;
}
foreach (SearchResult result in FindAll (monitor, provider, content, pattern, replacePattern, filter)) {
if (monitor.IsCancelRequested)
yield break;
FoundMatchesCount++;
yield return result;
}
if (replacePattern != null)
provider.EndReplace ();
if (SearchedFilesCount % step == 0)
monitor.Step (1);
}
} finally {
monitor.EndTask ();
IsRunning = false;
}
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:47,代码来源:FindReplace.cs
示例4: FindAll
public IEnumerable<SearchResult> FindAll (Scope scope, IProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter)
{
if (filter.RegexSearch) {
RegexOptions regexOptions = RegexOptions.Compiled;
if (!filter.CaseSensitive)
regexOptions |= RegexOptions.IgnoreCase;
regex = new Regex (pattern, regexOptions);
} else {
CompilePattern (pattern, filter);
}
IsRunning = true;
FoundMatchesCount = SearchedFilesCount = 0;
monitor.BeginTask (scope.GetDescription (filter, pattern, replacePattern), 100);
try {
int totalWork = scope.GetTotalWork (filter);
int step = Math.Max (1, totalWork / 100);
foreach (FileProvider provider in scope.GetFiles (monitor, filter)) {
if (monitor.IsCancelRequested)
break;
SearchedFilesCount++;
if (!string.IsNullOrEmpty (replacePattern))
provider.BeginReplace ();
foreach (SearchResult result in FindAll (monitor, provider, pattern, replacePattern, filter)) {
if (monitor.IsCancelRequested)
break;
FoundMatchesCount++;
yield return result;
}
if (!string.IsNullOrEmpty (replacePattern))
provider.EndReplace ();
if (SearchedFilesCount % step == 0)
monitor.Step (1);
DispatchService.RunPendingEvents ();
}
} finally {
monitor.EndTask ();
IsRunning = false;
}
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:40,代码来源:FindReplace.cs
示例5: GetDescription
public override string GetDescription (FilterOptions filterOptions, string pattern, string replacePattern)
{
if (string.IsNullOrEmpty (replacePattern))
return GettextCatalog.GetString ("Looking for '{0}' in project '{1}'", pattern, project.Name);
return GettextCatalog.GetString ("Replacing '{0}' in project '{1}'", pattern, project.Name);
}
开发者ID:acken,项目名称:monodevelop,代码行数:6,代码来源:Scope.cs
示例6: GetFiles
public override IEnumerable<FileProvider> GetFiles (IProgressMonitor monitor, FilterOptions filterOptions)
{
if (IdeApp.Workspace.IsOpen) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
foreach (ProjectFile file in project.Files) {
if (filterOptions.NameMatches (file.Name))
yield return new FileProvider (file.Name, project);
}
}
}
开发者ID:acken,项目名称:monodevelop,代码行数:10,代码来源:Scope.cs
示例7: GetTotalWork
public override int GetTotalWork (FilterOptions filterOptions)
{
return 1;
}
开发者ID:acken,项目名称:monodevelop,代码行数:4,代码来源:Scope.cs
示例8: GetFileNames
IEnumerable<string> GetFileNames (IProgressMonitor monitor, string path, bool recurse, FilterOptions filterOptions)
{
if (monitor != null)
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in '{0}'", path));
foreach (string fileMask in filterOptions.FileMask.Split (',', ';')) {
string[] files;
try {
files = Directory.GetFiles (path, fileMask, SearchOption.TopDirectoryOnly);
} catch (Exception e) {
LoggingService.LogError ("Can't access path " + path, e);
continue;
}
foreach (string fileName in files) {
if (fileName.StartsWith (".") && !IncludeHiddenFiles)
continue;
if (!IncludeBinaryFiles && MimeTypeIsBinary (DesktopService.GetMimeTypeForUri (fileName)))
continue;
yield return fileName;
}
if (recurse) {
foreach (string directoryName in Directory.GetDirectories (path)) {
if (directoryName.StartsWith (".") && !IncludeHiddenFiles)
continue;
foreach (string fileName in GetFileNames (monitor, Path.Combine (path, directoryName), recurse, filterOptions)) {
yield return fileName;
}
}
}
}
}
开发者ID:acken,项目名称:monodevelop,代码行数:32,代码来源:Scope.cs
示例9: FilterOptions
void ISearchDataSource.Activate (int item)
{
var options = new FilterOptions ();
if (PropertyService.Get ("AutoSetPatternCasing", true))
options.CaseSensitive = searchPattern.Pattern.Any (c => char.IsUpper (c));
FindInFilesDialog.SearchReplace (searchPattern.Pattern, null, new WholeSolutionScope (), options, null);
}
开发者ID:nsaydin,项目名称:monodevelop,代码行数:7,代码来源:SearchInSolutionSearchCategory.cs
示例10: GetFileNames
IEnumerable<string> GetFileNames(IProgressMonitor monitor, FilterOptions filterOptions)
{
if (monitor != null)
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in '{0}'", path));
var directoryStack = new Stack<string> ();
directoryStack.Push (path);
while (directoryStack.Count > 0) {
var curPath = directoryStack.Pop ();
try {
var readPermission = new FileIOPermission(FileIOPermissionAccess.Read, curPath);
readPermission.Demand ();
} catch (Exception e) {
LoggingService.LogError ("Can't access path " + curPath, e);
yield break;
}
foreach (string fileName in Directory.EnumerateFiles (curPath, "*")) {
if (!IncludeHiddenFiles) {
if (Platform.IsWindows) {
var attr = File.GetAttributes (fileName);
if (attr.HasFlag (FileAttributes.Hidden))
continue;
}
if (Path.GetFileName (fileName).StartsWith (".", StringComparison.Ordinal))
continue;
}
if (!filterOptions.NameMatches (fileName))
continue;
if (!IncludeBinaryFiles && !DesktopService.GetFileIsText (fileName))
continue;
yield return fileName;
}
if (recurse) {
foreach (string directoryName in Directory.EnumerateDirectories (curPath)) {
if (!IncludeHiddenFiles) {
if (Platform.IsWindows) {
var attr = File.GetAttributes (directoryName);
if (attr.HasFlag (FileAttributes.Hidden))
continue;
}
if (Path.GetFileName (directoryName).StartsWith (".", StringComparison.Ordinal))
continue;
}
directoryStack.Push (directoryName);
}
}
}
}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:52,代码来源:Scope.cs
示例11: GetFiles
public override IEnumerable<FileProvider> GetFiles (IProgressMonitor monitor, FilterOptions filterOptions)
{
if (IdeApp.Workspace.IsOpen) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
return project.Files.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name)).Select (f => new FileProvider (f.Name, project));
}
return Enumerable.Empty<FileProvider> ();
}
开发者ID:kirill85,项目名称:monodevelop,代码行数:8,代码来源:Scope.cs
示例12: SearchReplace
internal static void SearchReplace (string findPattern, string replacePattern, Scope scope, FilterOptions options, System.Action UpdateStopButton)
{
if (find != null && find.IsRunning) {
if (!MessageService.Confirm (GettextCatalog.GetString ("There is a search already in progress. Do you want to stop it?"), AlertButton.Stop))
return;
lock (searchesInProgress) {
foreach (var mon in searchesInProgress)
mon.AsyncOperation.Cancel ();
searchesInProgress.Clear ();
}
}
if (scope == null)
return;
find = new FindReplace ();
string pattern = findPattern;
if (!find.ValidatePattern (options, pattern)) {
MessageService.ShowError (GettextCatalog.GetString ("Search pattern is invalid"));
return;
}
if (replacePattern != null && !find.ValidatePattern (options, replacePattern)) {
MessageService.ShowError (GettextCatalog.GetString ("Replace pattern is invalid"));
return;
}
ThreadPool.QueueUserWorkItem (delegate {
using (ISearchProgressMonitor searchMonitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true)) {
searchMonitor.ReportStatus (scope.GetDescription (options, pattern, null));
lock (searchesInProgress)
searchesInProgress.Add (searchMonitor);
if (UpdateStopButton != null) {
Application.Invoke (delegate {
UpdateStopButton ();
});
}
DateTime timer = DateTime.Now;
string errorMessage = null;
try {
var results = new List<SearchResult> ();
foreach (SearchResult result in find.FindAll (scope, searchMonitor, pattern, replacePattern, options)) {
if (searchMonitor.IsCancelRequested)
return;
results.Add (result);
}
searchMonitor.ReportResults (results);
} catch (Exception ex) {
errorMessage = ex.Message;
LoggingService.LogError ("Error while search", ex);
}
string message;
if (errorMessage != null) {
message = GettextCatalog.GetString ("The search could not be finished: {0}", errorMessage);
searchMonitor.ReportError (message, null);
} else if (searchMonitor.IsCancelRequested) {
message = GettextCatalog.GetString ("Search cancelled.");
searchMonitor.ReportWarning (message);
} else {
string matches = string.Format (GettextCatalog.GetPluralString ("{0} match found", "{0} matches found", find.FoundMatchesCount), find.FoundMatchesCount);
string files = string.Format (GettextCatalog.GetPluralString ("in {0} file.", "in {0} files.", find.SearchedFilesCount), find.SearchedFilesCount);
message = GettextCatalog.GetString ("Search completed.") + Environment.NewLine + matches + " " + files;
searchMonitor.ReportSuccess (message);
}
searchMonitor.ReportStatus (message);
searchMonitor.Log.WriteLine (GettextCatalog.GetString ("Search time: {0} seconds."), (DateTime.Now - timer).TotalSeconds);
searchesInProgress.Remove (searchMonitor);
}
if (UpdateStopButton != null) {
Application.Invoke (delegate {
UpdateStopButton ();
});
}
});
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:80,代码来源:FindInFilesDialog.cs
示例13: Activate
public override void Activate ()
{
var options = new FilterOptions ();
if (PropertyService.Get ("AutoSetPatternCasing", true))
options.CaseSensitive = pattern.Pattern.Any (char.IsUpper);
FindInFilesDialog.SearchReplace (pattern.Pattern, null, new WholeSolutionScope (), options, null, null);
}
开发者ID:kdubau,项目名称:monodevelop,代码行数:7,代码来源:SearchInSolutionSearchCategory.cs
示例14: GetFiles
public override IEnumerable<FileProvider> GetFiles (ProgressMonitor monitor, FilterOptions filterOptions)
{
if (IdeApp.Workspace.IsOpen) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
var alreadyVisited = new HashSet<string> ();
var conf = project.DefaultConfiguration?.Selector;
foreach (ProjectFile file in project.GetSourceFilesAsync (conf).Result.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name))) {
if ((file.Flags & ProjectItemFlags.Hidden) == ProjectItemFlags.Hidden)
continue;
if (!IncludeBinaryFiles && !DesktopService.GetFileIsText (file.Name))
continue;
if (alreadyVisited.Contains (file.FilePath.FullPath))
continue;
alreadyVisited.Add (file.FilePath.FullPath);
yield return new FileProvider (file.Name, project);
}
}
}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:18,代码来源:Scope.cs
示例15: GetFiles
public override IEnumerable<FileProvider> GetFiles (IProgressMonitor monitor, FilterOptions filterOptions)
{
if (IdeApp.Workspace.IsOpen) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Looking in project '{0}'", project.Name));
foreach (ProjectFile file in project.Files.Where (f => filterOptions.NameMatches (f.Name) && File.Exists (f.Name))) {
if (!IncludeBinaryFiles && !DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (file.Name)))
continue;
yield return new FileProvider (file.Name, project);
}
}
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:11,代码来源:Scope.cs
示例16: GetDescription
public override string GetDescription (FilterOptions filterOptions, string pattern, string replacePattern)
{
if (replacePattern == null)
return GettextCatalog.GetString ("Looking for '{0}' in directory '{1}'", pattern, path);
return GettextCatalog.GetString ("Replacing '{0}' in directory '{1}'", pattern, path);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:6,代码来源:Scope.cs
注:本文中的MonoDevelop.Ide.FindInFiles.FilterOptions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论