public void HandleMessage(Message message, RouterSocket shellSocket, PublisherSocket ioPubSocket)
        {
            var executeRequest = JsonSerializer.Deserialize <ExecuteRequest>(message.Content);

            Log.Info($"Execute Request received with code {executeRequest.Code}");

            // Kernel sends a "status: busy" message on IOPub
            SendMessageToIoPub(message, ioPubSocket, StatusValues.Busy);

            // Kernel
            SendInputMessageToIoPub(message, ioPubSocket, executeRequest.Code);

            // 3: Evaluate the C# code
            var result = InteractiveShell.ExecuteCode(executeRequest.Code);

            // 4: Send execute reply to shell socket
            SendExecuteReplyMessage(message, shellSocket);

            // 5: Send execute result message to IOPub
            SendOutputMessageToIoPub(message, ioPubSocket, result);

            // 6: Send IDLE status message to IOPub
            SendMessageToIoPub(message, ioPubSocket, StatusValues.Idle);

            _executionCount += 1;
        }
예제 #2
0
파일: Program.cs 프로젝트: tinmanjk/SQLNado
        static void SafeMain(string[] args)
        {
            Console.WriteLine("SqlNado.Cli - Copyright © 2016-" + DateTime.Now.Year + " Simon Mourier. All rights reserved.");
            Console.WriteLine();
            if (CommandLine.HelpRequested || args.Length < 1)
            {
                Help();
                return;
            }

            var traces = CommandLine.GetArgument("traces", false);

            Console.CancelKeyPress += (sender, e) => e.Cancel = true;
            string path = Path.GetFullPath(args[0]);

            Console.WriteLine("Path: " + path);
            Console.WriteLine();
            var shell = new InteractiveShell();

            if (traces)
            {
                shell.Logger = new ConsoleLogger(true);
            }
            shell.Run(path);
            Console.WriteLine();
            Console.WriteLine("Exited.");
        }
예제 #3
0
        static void Main(string[] args)
        {
            ArgParse.Parse(args);
            var ds = new InteractiveShell();

            ds.CmdLoop();
        }
예제 #4
0
        static void RealWorlExampleMain()
        {
            Console.WriteLine("Real world example");

            InteractiveShell interactiveShell = new InteractiveShell();

            interactiveShell.Run();
        }
        public void can_start_interact_with_and_stop_a_process()
        {
            using (var subject = new InteractiveShell(">", "bye"))
            {
                subject.Start("./ExampleInteractiveProcess.exe", Directory.GetCurrentDirectory());

                var intro = subject.ReadToPrompt();
                Assert.That(intro.Item1, Is.StringStarting(ExampleProcess.Program.Intro));

                var interact = subject.SendAndReceive("This is a test");
                Assert.That(interact.Item1, Is.StringStarting("You wrote This is a test"));

                Assert.That(subject.IsAlive());

                subject.Terminate();
                Assert.That(subject.IsAlive(), Is.False);
            }
            Assert.Pass();
        }
예제 #6
0
        static void Main(string[] args)
        {
            // Create a new instance of the ShellMenu class.
            InteractiveShell menu = new InteractiveShell();

            // Create the options for theming.
            ShellDisplayOptions displayOptions = new ShellDisplayOptions()
            {
                LeftOffset          = 2,
                DisplayHorizontally = false
            };
            ShellTitleDisplayOptions titleDisplayOptions = new ShellTitleDisplayOptions()
            {
                LeftOffset = 2
            };

            // We will use these fallbacks, notice how we specify `null` for the displayOptions parameters,
            // these can be omitted as they are optional parameters but have been explicitly set to null to make the intent clearer.
            menu.FallbackDisplayOptions      = displayOptions;
            menu.FallbackTitleDisplayOptions = titleDisplayOptions;

            //
            // Single choice menu
            //

            // Draw the title, clearing the screen beforehand
            menu.DrawTitle(title: "Sample Menu", subtitle: "Select a single option:", "Content test", displayOptions: null, clearScreen: true);

            // Present the user with the interactive menu
            int result = menu.DisplayMenu(options: new string[] { "Option 1", "Option 2" }, footerTexts: null, displayOptions: null);

            switch (result)
            {
            case 0:
                // Do Option 1
                break;

            case 1:
                // Do Option 2
                break;
            }

            //
            // Multi-choice menu
            //

            // Draw the title, clearing the screen beforehand
            menu.DrawTitle(title: "Sample Menu", subtitle: "Select multiple options with Control + Enter:", displayOptions: null, clearScreen: true);

            // Present the user with the interactive menu
            int[] results = menu.DisplayMultiMenu(options: new string[] { "Option 1", "Option 2", "Option 3" },
                                                  footerTexts: new string[] { "Footer 1", "Footer 2", "Footer 3" }, displayOptions: null);

            // Print out the selected indexes
            menu.DrawContentText("\nSelected indexes:", false);
            foreach (var index in results)
            {
                menu.DrawContentText(index.ToString(), false);
            }

            menu.Reset();
            Console.ReadKey();
        }