Пример #1
0
        public void update()
        {
            List <string> pluginNames = getPluginNames(); // get names from config.xml of plugin names

            foreach (var item in pluginNames)
            {
                try
                {
                    Tuple <string, decimal, string> tmpCurrency = getCurrencyFromPlugin(item); // get currency from *.dll plugins
                    CurrenciesList.Add(new Currency()
                    {
                        Name = tmpCurrency.Item1, value = tmpCurrency.Item2
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                    Trace.WriteLine(e.ToString());
                    foreach (var item_ in Trace.Listeners)
                    {
                        Debug.WriteLine(item_.ToString());
                    }
                }
            }

            saveCurrencies();      // saves the list of currencies to the XML

            PluginAdded?.Invoke(); // invoke publisher for the event of PluginAdded
        }
Пример #2
0
        public void LoadPlugins(IPluginHost host)
        {
            var dir        = _options.PluginDir;
            var pluginDirs = Directory.GetDirectories(dir);
            var list       = new List <DirectoryCatalog>();
            var def        = new ImportDefinition(d => d.ContractName == typeof(IPlugin).FullName, "", ImportCardinality.ExactlyOne, false, false);
            var plugins    = new List <IPlugin>();

            foreach (var pluginDir in pluginDirs)
            {
                var files = Directory.GetFiles(pluginDir).Where(s => s.EndsWith("Plugin.dll"));//ファイル名がPlugin.dllで終わるアセンブリだけ探す
                foreach (var file in files)
                {
                    try
                    {
                        var catalog = new AssemblyCatalog(file);
                        var con     = new CompositionContainer(catalog);
                        var plugin  = con.GetExport <IPlugin>().Value;
                        plugins.Add(plugin);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
                list.Add(new DirectoryCatalog(pluginDir));
            }
            _plugins = plugins;
            foreach (var plugin in _plugins)
            {
                plugin.Host = host;
                PluginAdded?.Invoke(this, plugin);
            }
        }
Пример #3
0
        public void AddPlugin(string fileName)
        {
            var fileInfo = new FileInfo(fileName);
            var plugin   = LoadPlugin(fileInfo);

            LoadedPlugins.Add(plugin);
            PluginAdded?.Invoke(this, plugin);
        }
 private void OnPluginAdded(DeviceToolPayload payload, List <ToolViewModel> viewModels)
 {
     PluginAdded?.Invoke(payload, viewModels);
 }