Exemple #1
0
        static void Main(string[] args)
        {
            //设置应用程序处理异常方式:ThreadException处理
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Console.WriteLine("Starting...");


            string pluginFolder = ConfigurationManager.AppSettings["PluginFolder"];

            pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, pluginFolder);
            if (!Directory.Exists(pluginFolder))
            {
                Directory.CreateDirectory(pluginFolder);
            }

            HostApp.PlugMgr.LoadPlugins(AppDomain.CurrentDomain.BaseDirectory);
            HostApp.PlugMgr.LoadPlugins(pluginFolder);
            foreach (var item in Directory.EnumerateDirectories(pluginFolder))
            {
                HostApp.PlugMgr.LoadPlugins(item);
            }

            foreach (string key in HostApp.PlugMgr.Plugins.Keys)
            {
                Console.WriteLine("Loaded Plugin: {0}", key);
            }

            // register exit event
            HostApp.Exited += HostApp_Exited;

            //Host startup
            try
            {
                HostApp.StartUp();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
 public void StartUpTest()
 {
     HostApp.PlugMgr.LoadPlugins(Directory.GetCurrentDirectory());
     HostApp.StartUp();
     Assert.AreEqual(2, HostApp.PlugMgr.Plugins.Count);
 }