예제 #1
0
        private static int RunInteractiveMode(InteractiveModeOptions opts)
        {
            Console.CancelKeyPress += (s, e) =>
            {
                e.Cancel = true;
                Environment.Exit(0);
            };

            Console.WriteLine("Press Ctrl + C to stop the program..");

            while (true)
            {
                try
                {
                    Console.WriteLine("Input expression to parse:");
                    var expression = Console.ReadLine();
                    if (string.IsNullOrEmpty(expression))
                    {
                        continue;
                    }

                    var result = ExpressionParser.Parse(expression);
                    Console.WriteLine($"Canonical form: {result}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unexpected exception on expression processing: {0}", ex.Message);
                    Console.WriteLine("Please check your expression");
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes an instance of <see cref="ScopeResetDirective"/>.
 /// </summary>
 public ScopeResetDirective(IOptions <InteractiveModeOptions> options)
 {
     _options = options.Value;
 }
예제 #3
0
 /// <summary>
 /// Initializes an instance of <see cref="ScopeDirective"/>.
 /// </summary>
 public ScopeDirective(IOptions <InteractiveModeOptions> options, ICliContext cliContext)
 {
     _options    = options.Value;
     _cliContext = cliContext;
 }