using System; using System.IO; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Windows.Forms; using DataStreamInterface; namespace DataStreamInterfaceTest { class Program { #if DEBUG const string CatalogDir = "..\\..\\..\\DataStreamMeter\\bin\\Debug"; #else const string CatalogDir = "..\\..\\..\\DataStreamMeter\\bin\\Release"; #endif [Import(typeof(IDataStreamMeter))] IDataStreamMeter dataStreamMeter; private Program() { Console.WriteLine("Components found:"); foreach (var file in Directory.EnumerateFiles(CatalogDir)) { Console.WriteLine(file); } try { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(DataStreamInterface.IDataStreamMeter).Assembly)); catalog.Catalogs.Add(new DirectoryCatalog(CatalogDir)); (new CompositionContainer(catalog)).ComposeParts(this); } catch (CompositionException compositionException) { Console.WriteLine(compositionException.ToString()); } } /// /// The main entry point for the application. /// [STAThread] static void Main() { Program p = new Program(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DemoMainWnd(p.dataStreamMeter)); } } }