예제 #1
0
 public void LoadPlugin(PluginObj plugin)
 {
     _plugin = plugin;
     name.Text += plugin.ConfigAdaptor.Name;
     Author.Text += plugin.ConfigAdaptor.Author;
     Version.Text += plugin.ConfigAdaptor.Version;
     Description.Text += plugin.ConfigAdaptor.Description;
     foreach (Command command in plugin.ConfigAdaptor.Commands)
         CommandList.Controls.Add(new Item_command(command));
 }
예제 #2
0
 public void CheckCommand(PluginObj plugin, string commands_directory)
 {
     try
     {
         DirectoryInfo Dir = new DirectoryInfo(commands_directory);
         string JsonFileName;
         string SerializedCommands;
         foreach (var file in Dir.GetFiles("*.json"))
         {
             JsonFileName = file.Name.Substring(0, file.Name.IndexOf(".json"));
             if (HttpUtility.UrlDecode(JsonFileName) == plugin.ConfigAdaptor.Name)
             {
                 SerializedCommands = System.IO.File.ReadAllText(commands_directory + HttpUtility.UrlEncode(plugin.ConfigAdaptor.Name) + ".json");
                 Commands DeSerializedCommands = JsonConvert.DeserializeObject<Commands>(SerializedCommands);
                 plugin.ConfigAdaptor.SetCommands(DeSerializedCommands);
                 OnMessage(this, Environment.NewLine + "Loaded commands for " + plugin.ConfigAdaptor.Name + Environment.NewLine);
             }
         }
     }
     catch (Exception ex)
     {
         OnError(this, ex);
     }
 }
예제 #3
0
 private void PluginManager_OnPluginLoaded(PluginObj plugin)
 {
     try
     {
        pluginmanager.CheckCommand(plugin, _commands_directory);
     }
     catch (Exception ex)
     {
         OnError(this, ex);
     }
 }
예제 #4
0
파일: Main.cs 프로젝트: MaxbuzzTM/TeleGraph
 private void CPlugin1_OnSaveChanges(Commands commands, PluginObj plugin)
 {
     manager.PluginManager.SaveCommand(Commands_Directory.Text, commands, plugin.ConfigAdaptor.Name);
     MessageBox.Show("Saved Commands!");
 }
예제 #5
0
        public void LoadPlugins()
        {
            try
            {
                DirectoryInfo Dir = new DirectoryInfo(PluginFolder);
                string PluginName;
                foreach (var file in Dir.GetFiles("*.dll"))
                {

                    PluginName = file.Name.Substring(0, file.Name.IndexOf(".dll"));
                    if (pluginvalidator.IsPLuginValid(PluginFolder, PluginName))
                    {
                        PluginObj p = new PluginObj();
                        p.OnError += P_OnError;
                        p.Load(PluginFolder, PluginName, pluginadapter);
                        plugins.Add(p);
                        OnPluginLoaded(p);
                    }
                }
            }
            catch (Exception ex)
            {
                OnError(this, ex);
            }
        }