static int Main(string[] args) { string wDir = "", sString = "", Patterns = ""; bool incDirs = false; if (!ProcessCommandLineArgs(args, ref wDir, ref sString, ref Patterns, ref incDirs)) { ShowUsage(); return(1); } try { "Starting CSharpClient for TextSearch & FileManager Components".Title('=', 22); Console.Write("\r\n Creating proxy to ITextSearch COM ATL Library"); txtSearch = new TextSearch(); Console.Write("\r\n Creating proxy to IFileManager COM ATL Library"); IFileManager fmgr = new FileManager(); Console.Write("\r\n Passing the instance of TextSearch to FileManager instance"); fmgr.ConfigureSearcher(txtSearch); Console.Write($"\r\n Setting working directory of IFileManager to: '{wDir}' and filter pattern to: '{Patterns}'"); fmgr.SetWorkingDirectory(wDir, Patterns, incDirs); Console.Write($"\r\n Setting search string to '{sString}'"); fmgr.SetSearchString(sString); Console.Write("\r\n FileManager instance is now sending the found files to TextSearch instance"); fmgr.PerformOperations(); Console.Write("\r\n Ordering FileManager to terminate its ITextSearch instance after it has finished by sending 'quit' message\r\n"); fmgr.TerminateSearcher(); Console.Write("\r\n\r\n Files found by FileManager: "); int c = 0; while (fmgr.good()) { string file = ""; fmgr.GetFile(out file); // last entry is always null in filemanager if (file == null) { break; } Console.Write($"\r\n {(++c).ToString().PadLeft(2)} - '{file}'"); } Console.WriteLine(); Thread t = new Thread(ThreadProc); t.Start(); t.Join(); } catch (Exception ex) { Console.WriteLine($"\r\n\r\n Error thrown. Details: {ex.Message}"); return(1); } return(0); }
public FileInfo[] GetFilesInFolder(string folderPath, bool recursive, ITextSearch plugin){ if (plugin == null) plugin = new NullPlugin(); if (_cancellationPending){ plugin.Reset(); return new FileInfo[0]; } var filesInFolder = GetFilesInFolder(folderPath, plugin); filesInFolder.ToList().ForEach(fi => plugin.RegisterFileToProcess(fi.FullName)); if(!recursive) return filesInFolder; var fileInfoList = new List<FileInfo>(filesInFolder); try{ string[] directories = Directory.GetDirectories(folderPath); foreach (var directoryPath in directories) fileInfoList.AddRange(GetFilesInFolder(directoryPath, true, plugin)); } catch (Exception ex){ LogError("File access problem", ex.Message); } return fileInfoList.ToArray(); }
public TextSearchDialog(ITextSearch searcher) { InitializeComponent(); this.searcher = searcher; }
private void Unbind(ITextSearch plugin) { plugin.OnNotify -= plugin_OnNotify; }
private void Bind(ITextSearch plugin){ plugin.OnNotify += plugin_OnNotify; }
public void SelectPlugin(ITextSearch plugin){ if (_engine.CurrentPlugin != null) Unbind(_engine.CurrentPlugin); _engine.CurrentPlugin = plugin; if (_engine.CurrentPlugin != null) Bind(_engine.CurrentPlugin); if (OnSearchEnabled != null) OnSearchEnabled(this, new EnableStateEventArgs(_engine.CurrentPlugin != null)); var pluginProperties = new List<PluginProperty>(); if (_engine.CurrentPlugin != null){ _engine.CurrentPlugin.Reset(); pluginProperties = _engine.CurrentPlugin.Properties; } View.RefreshPluginProperties(pluginProperties); }
private bool whereCondition(TestObjectNurse nurseObject) { ITextSearch searchObject = nurseObject as ITextSearch; return(searchObject.ContainsKeyword(_keyword)); }
private static int GetIndexAfterFoundWord4(string text, string searchWord, ITextSearch textSearch) { int[] found = textSearch.Find(text, searchWord); return(found.First() + searchWord.Length); }
public void RegisterPlugin(ITextSearch plugin){ Plugins.Add(plugin); }
private FileInfo[] GetFilesInFolder(string folderPath, ITextSearch plugin){ return GetFilesInFolder(folderPath, plugin.SearchPattern); }
public IndexIterator(ITextSearch textSearch) { _textSearch = textSearch; }