public void Init() { WmiProcessWatcher.Start(); PluginsContainer = GoToWindowPluginsContainer.LoadPlugins(); _mainWindow.DataContext = _mainViewModel; _mainViewModel.Close += _mainViewModel_Hide; }
public static GoToWindowPluginsContainer LoadPlugins() { var catalog = new AggregateCatalog(); try { catalog.Catalogs.Add(new DirectoryCatalog(PluginsFolderName)); } catch (DirectoryNotFoundException exc) { HandleError(exc, ExitCodes.PluginDirectoryNotFound, "Plugins directory not found. Check that the Plugins directory is created and at least contains at least GoToWindow.Plugins.Core.dll can be found and restart GoToWindow."); return(null); } var container = new CompositionContainer(catalog); try { var pluginsContainer = new GoToWindowPluginsContainer(); container.ComposeParts(pluginsContainer); DiagnosticCatalogComposition(catalog); if (pluginsContainer.Plugins == null || !pluginsContainer.Plugins.Any()) { HandleError(new Exception("No plugins were composed"), ExitCodes.NoPluginsFound, "No plug-ins found. Check that at least GoToWindow.Plugins.Core.dll can be found in the Plugins directory and restart GoToWindow."); return(null); } pluginsContainer.Plugins = pluginsContainer.Plugins.OrderBy(plugin => plugin.Sequence).ToList(); return(pluginsContainer); } catch (InstanceNotFoundException exc) { HandleError(exc, ExitCodes.NoPluginsFound, "No plug-ins found. Check that at least GoToWindow.Plugins.Core.dll can be found in the Plugins directory and restart GoToWindow."); return(null); } catch (ReflectionTypeLoadException exc) { HandleError(exc, ExitCodes.ErrorLoadingPluginsTypes, "An error occured while loading plugin types.", string.Join("; ", exc.LoaderExceptions.Select(e => e.Message))); return(null); } catch (Exception exc) { HandleError(exc, ExitCodes.ErrorLoadingPlugins, "An error occured while loading plug-ins. Try updating or removing plugins other than GoToWindow.Plugins.Core.dll from the Plugins directory and restart GoToWindow."); return(null); } }
public static GoToWindowPluginsContainer LoadPlugins() { var catalog = new AggregateCatalog(); try { catalog.Catalogs.Add(new DirectoryCatalog(PluginsFolderName)); } catch (DirectoryNotFoundException exc) { HandleError(exc, ExitCodes.PluginDirectoryNotFound, "Plugins directory not found. Check that the Plugins directory is created and at least contains at least GoToWindow.Plugins.Core.dll can be found and restart GoToWindow."); return null; } var container = new CompositionContainer(catalog); try { var pluginsContainer = new GoToWindowPluginsContainer(); container.ComposeParts(pluginsContainer); if(pluginsContainer.Plugins == null || !pluginsContainer.Plugins.Any()) throw new InstanceNotFoundException("No plug-ins found"); pluginsContainer.Plugins = pluginsContainer.Plugins.OrderBy(plugin => plugin.Sequence).ToList(); return pluginsContainer; } catch (InstanceNotFoundException exc) { HandleError(exc, ExitCodes.NoPluginsFound, "No plug-ins found. Check that at least GoToWindow.Plugins.Core.dll can be found in the Plugins directory and restart GoToWindow."); return null; } catch (Exception exc) { HandleError(exc, ExitCodes.ErrorLoadingPlugins, "An error occured while loading plug-ins. Try updating or removing plugins other than GoToWindow.Plugins.Core.dll from the Plugins directory and restart GoToWindow."); return null; } }
public void Init() { WmiProcessWatcher.Start(); PluginsContainer = GoToWindowPluginsContainer.LoadPlugins(); }