private void ReIgnite(object sender, System.ComponentModel.CancelEventArgs e) { bool needsToExtinguish = false; foreach (string assembly in Directory.GetFiles("Plugins", "*.dll", SearchOption.TopDirectoryOnly)) { Assembly plugin = Assembly.LoadFrom(assembly); // Get the type to use. var results = from type in plugin.GetTypes() where typeof(IFlameable).IsAssignableFrom(type) select type; foreach (Type type in results) { IFlameable flamable = Activator.CreateInstance(type) as IFlameable; if (!Plugins.Contains(flamable, new FlamableComparer())) { needsToExtinguish = true; } } } if (needsToExtinguish) { Extinguish(); Ignite(); } }
private void Ignite() { foreach (string assembly in Directory.GetFiles("Plugins", "*.dll", SearchOption.TopDirectoryOnly)) { Assembly plugin = Assembly.LoadFrom(assembly); // Get the type to use. var results = from type in plugin.GetTypes() where typeof(IFlameable).IsAssignableFrom(type) select type; foreach (Type type in results) { IFlameable flamable = Activator.CreateInstance(type) as IFlameable; Plugins.Add(flamable); flamable.Ingnite(NotifyIcon); } } NotifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Quit", null, Exit, "Quit")); }