コード例 #1
0
        public override bool Execute(OpenInput input)
        {
            input.CreateMissingSpecFolder();



            using (var app = new ApplicationController(input, input.BuildEngine(), new WebApplicationRunner(input)))
            {
                app.Start();

                Console.WriteLine("Launching the browser to " + app.Website.BaseAddress);

                ProcessLauncher.GotoUrl(app.Website.BaseAddress);

#if NET46
                AppDomain.CurrentDomain.DomainUnload += (sender, args) =>
                {
                    app.SafeDispose();
                };
#else
                System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += context => app.Dispose();
#endif

                Console.CancelKeyPress += (s, e) =>
                {
                    Console.WriteLine("Shutdown detected, tearing down the testing harness...");
                    app.SafeDispose();
                };

                tellUsersWhatToDo(app.Website.BaseAddress);

                while (true)
                {
                    var key = Console.ReadKey();
                    if (key.Key == ConsoleKey.Q)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Shutting down the Storyteller documentation preview runner....");
                        app.SafeDispose();
                        Console.WriteLine("Done, exiting...");

                        break;
                    }
                }
            }


            return(true);
        }
コード例 #2
0
ファイル: OpenCommand.cs プロジェクト: vgrigoriu/Storyteller
        public override bool Execute(OpenInput input)
        {
            input.CreateMissingSpecFolder();

            var reset = new ManualResetEvent(false);


            using (var app = new ApplicationController(input, input.BuildEngine(), new WebApplicationRunner(input)))
            {
                app.Start();

                Console.WriteLine("Launching the browser to " + app.Website.BaseAddress);

                ProcessLauncher.GotoUrl(app.Website.BaseAddress);

#if NET46
                AppDomain.CurrentDomain.DomainUnload += (sender, args) =>
                {
                    app.SafeDispose();
                };
#else
                System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += context => app.Dispose();
#endif

                Console.CancelKeyPress += (s, e) =>
                {
                    Console.WriteLine("Shutdown detected, tearing down the testing harness...");
                    app.SafeDispose();
                    reset.Set();
                };

                tellUsersWhatToDo(app.Website.BaseAddress);
                reset.WaitOne();
            }


            return(true);
        }