// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.IO; using System.Reflection; namespace E { public class Test { private List plugins = new List(); private void Setup() { foreach(string fnm in Directory.GetFiles(@"C:\work\plugin", "*.plu")) { foreach(Type typ in Assembly.LoadFrom(fnm).GetTypes()) { if(typeof(IHelloWorld).IsAssignableFrom(typ)) { plugins.Add((IHelloWorld)typ.GetConstructor(new Type[0]).Invoke(new object[0])); } } } } private void DoAll() { foreach(IHelloWorld plugin in plugins) { plugin.Say(); } } public static void Main(string[] args) { Test o = new Test(); o.Setup(); o.DoAll(); } } }