public PluginManager(Telegram.Bot.Api _Api, string plugin_directory) { try { PluginFolder = plugin_directory; client.OnTaskDone += OnTaskDone; client.Api = _Api; client.Id = 9914; pluginadapter = new PluginAdaptor(client); pluginadapter.Onerror += (sender, error) => { OnError(sender, error); }; pluginadapter.Onmessage += (sender, message) => { OnMessage(sender, message); }; } catch (Exception ex) { OnError(this, ex); } }
public void Load(string pluginfolder, string pluginname, PluginAdaptor pluginadaptor) { try { _pluginname = pluginname; pluginAsm = Assembly.LoadFile(pluginfolder + _pluginname + ".dll"); CoreType = pluginAsm.GetType(_pluginname + ".Main"); Core = Activator.CreateInstance(CoreType); ClientPropertyInfo = CoreType.GetProperty("PluginAdapter"); ClientPropertyInfo.SetValue(Core, pluginadaptor, null); ConfigPropertyInfo = CoreType.GetProperty("Config"); Config config = (Config)ConfigPropertyInfo.GetValue(Core, null); configAdaptor = new ConfigAdapter(config); configAdaptor.OnError += ConfigAdaptor_OnError; } catch (Exception ex) { OnError(this, ex); } }