// 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.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection; namespace E { public class Test { [ImportMany] private List plugins = null; private void DoAll() { foreach(IHelloWorld plugin in plugins) { plugin.Say(); } } public static void Main(string[] args) { Test o = new Test(); AggregateCatalog cat = new AggregateCatalog(); cat.Catalogs.Add(new DirectoryCatalog(@"C:\work\plugin", "*.plu")); CompositionContainer container = new CompositionContainer(cat); container.SatisfyImportsOnce(o); o.DoAll(); } } }