public void Refresh() { itemsView.Children.Clear(); foreach (var plugin in _manager.GetPlugins()) { var itemView = new ItemView(); itemView.Icon = Icons.Icon.Layer; itemView.Content = plugin.Name; itemView.Margin = new Thickness(1); itemView.Tag = _manager .GetPluginsTypesInfos() .Where(x => x.Plugin.Equals(plugin)) .Select(x => x.Type) .ToArray(); itemsView.Children.Add(itemView); } if (itemsView.GetItems().Any()) { itemsView.GetItems().First().Selected = true; } else { btRemovePlugin.Visibility = Visibility.Collapsed; spPluginTypes.Children.Clear(); } }
private void btnDeletePlugin_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.Cancel) { return; } PluginsManager.DeletePlugin(openFileDialog.FileName); comboBoxPlugin.DataSource = PluginsManager.GetPlugins(); }
public void RemoveLibTest() { Singleton.Add(new FileSavior()); var modulesManager = new PluginsManager(); modulesManager.RemovePlugin(modulesManager.GetPlugins().First().Name); if (modulesManager.GetModules().Any(x => x.Name.Contains("TestAction"))) { throw new Exception(); } }
private void btnLoadPlugin_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.Cancel) { return; } if (openFileDialog.FileName.EndsWith(".dll")) { PluginsManager.LoadPlugin(openFileDialog.FileName); comboBoxPlugin.DataSource = PluginsManager.GetPlugins(); } else { MessageBox.Show("Plugin file should be .dll file"); } }
static void Main(string[] args) { PluginsManager pManager = PluginsManager.Instance; Console.WriteLine($"Current plugins count: {pManager.PluginCount}"); Console.WriteLine($"HasType DataLoader? Answer: {pManager.HasType(PluginType.DataLoader)}"); Console.WriteLine($"HasPlugin DataLoader? Answer: {pManager.HasType(PluginType.DataLoader)}"); var config = new CsvFileConfiguration(@"C:\temp\config.txt"); Console.WriteLine($"Loading plugin TestPlugin's configuration, result is: {pManager.LoadPluginConfiguration(PluginType.DataLoader, "TestPlugin",config)}"); Console.WriteLine($"Running plugin TestPlugin, result is: {pManager.ExecutePlugin(PluginType.DataLoader, "TestPlugin")}"); Console.WriteLine($"Printing current available plugins"); foreach (var plugin in pManager.GetPlugins()) { Console.WriteLine($"Name: {plugin.Name}, Description: {plugin.Description}, Version: {plugin.Version}, Type: {plugin.Type}"); } Console.ReadKey(); }
public MainForm() { InitializeComponent(); comboBoxPlugin.DataSource = PluginsManager.GetPlugins(); comboBoxPlugin.DisplayMember = "Name"; Assembly SerializationAsm = Assembly.LoadFrom("Serialization_lib.dll"); List <ControlInfoAttribute> Attributes = new List <ControlInfoAttribute>(); foreach (Type t in SerializationAsm.GetTypes()) { object[] attrs = t.GetCustomAttributes(typeof(ControlInfoAttribute), false); if (attrs.Length > 0) { Attributes.Add((ControlInfoAttribute)attrs[0]); } } comboBoxType.DataSource = Attributes; comboBoxType.DisplayMember = "Text"; comboBoxType.ValueMember = "type"; Assembly CRUDAsm = Assembly.LoadFrom("CRUD_lib.dll"); List <Type> Types = new List <Type>(); foreach (Type t in CRUDAsm.GetTypes()) { if (!t.IsAbstract && !t.IsSubclassOf(typeof(Attribute)) && !t.IsEnum) { Types.Add(t); } } comboBox.DataSource = Types; comboBox.DisplayMember = "Name"; comboBox.SelectedItem = comboBox.Items[0]; }
private void btnOpen_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.Cancel) { return; } string FileName = openFileDialog.FileName; if (!FileName.EndsWith(".dat")) { var plugins = PluginsManager.GetPlugins(); bool IsPluginExist = false; foreach (var plugin in plugins) { if (FileName.EndsWith(plugin.Extension)) { IsPluginExist = true; FileName = plugin.Decompress(new FileInfo(FileName)); break; } } if (!IsPluginExist) { MessageBox.Show("No plugin for this type of file"); return; } } ISerializer serializer = (ISerializer)Activator.CreateInstance((Type)comboBoxType.SelectedValue); using (FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate)) { SetUserCreatedObjs(serializer.Deserialize(fs)); } }
public AdminModulos(PluginsManager pl) { InitializeComponent(); pList = pl.GetPlugins(); plugins = pl; }