protected override void OnStart(string[] args) { try { log.Info("Initiating on start"); var catalog = new AggregateCatalog( new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog("extensions")); log.Info("Getting container"); var container = new CompositionContainer(catalog); log.Info("instance plugins"); var plugins = new Plugins(); log.Info("get compose parts"); container.ComposeParts(plugins); plugins.Initialize(); while (true) { log.Info("Plugin analyze"); plugins.Analyze(); Thread.Sleep(60000); } } catch (Exception ex) { log.ErrorFormat("error : {0}", ex.Message); } }
static void Main(string[] args) { var catalog = new AggregateCatalog( new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog("extensions")); var container = new CompositionContainer(catalog); var plugins = new Plugins(); container.ComposeParts(plugins); plugins.Analyze(); Console.ReadLine(); }