public void Start( string path, ICacheBuilder cache, ICrawlResult crawlReader, PluginLocator pluginLocator, EventEndpoint eventDispatcher) { _cache = cache; _crawlReader = crawlReader; _eventDispatcher = eventDispatcher; _tracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); pluginLocator.Locate().ToList() .ForEach(x => { var plugin = new PluginPattern(x); _plugins.Add(plugin); _cache.Plugins.Add( new CachedPlugin(x.GetLanguage(), plugin.Patterns)); }); _tracker.Start(path, getFilter(), handleChanges); }
public void Start( string path, ICacheBuilder cache, ICrawlResult crawlReader, PluginLocator pluginLocator, EventEndpoint eventDispatcher) { _cache = cache; _crawlReader = crawlReader; _eventDispatcher = eventDispatcher; Logger.Write("Setting up file trackers"); Logger.Write("Setting up token file trackers"); _tracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up local file trackers"); _localTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up global file trackers"); _globalTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Adding plugins to cache"); var plugins = pluginLocator.Locate().ToList(); foreach (var x in plugins) { var plugin = new PluginPattern(x); _plugins.Add(plugin); _cache.Plugins.Add( new CachedPlugin(x.GetLanguage(), plugin.Patterns)); Logger.Write("Added plugin " + x.GetLanguage()); } Logger.Write("Starting tracker for {0}", path); _tracker.Start(path, getFilter(), handleChanges); var locator = new ProfileLocator(path); if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile()); if (Directory.Exists(profilePath)) { Logger.Write("Starting tracker for {0}", profilePath); _localTracker.Start(profilePath, getFilter(), handleChanges); } } var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile()); if (Directory.Exists(globalPath)) { Logger.Write("Starting tracker for {0}", globalPath); _globalTracker.Start(globalPath, getFilter(), handleChanges); } }
private static void shutdownPlugins(PluginLocator locator) { try { var plugins = locator.Locate(); foreach (var plugin in plugins) { try { Logger.Write("Shutting down plugin " + plugin.GetLanguage()); plugin.Shutdown(); } catch (Exception ex) { Logger.Write(ex.ToString()); } } } catch { } }
private static void initPlugins(PluginLocator locator) { var plugins = locator.Locate(); foreach (var plugin in plugins) { try { plugin.Initialize(_path); plugin.GetCrawlFileTypes(); ThreadPool.QueueUserWorkItem( (o) => { try { var currentPlugin = (LanguagePlugin)o; var handler = new CrawlHandler(_cache, (s) => Logger.Write(s)); handler.SetLanguage(currentPlugin.GetLanguage()); currentPlugin.Crawl(new string[] { _path }, (line) => handler.Handle(line)); } catch (Exception ex) { Logger.Write(ex.ToString()); } }, plugin); } catch (Exception ex) { Logger.Write(ex.ToString()); } } Logger.Write("Plugins initialized"); }
private static void initPlugins(PluginLocator locator, CrawlHandler handler) { new Thread(() => { locator.Locate().ToList() .ForEach(x => { try { handler.SetLanguage(x.GetLanguage()); foreach (var line in x.Crawl(new string[] { _path })) handler.Handle(line); } catch (Exception ex) { Logger.Write(ex.ToString()); } }); }).Start(); }