Example #1
0
        /// <summary>
        /// Popupates the main application context with effective settings for a console application
        /// </summary>
        public void ConfigureConsole(MainApplicationContext context)
        {
            context.IsAtty   = IsAtty.Value;
            context.TimeZone = TimeZoneId.Value;

            Console.OutputEncoding = OutputEncoding.Value;
            if (AnsiTerminalEmulation.Value)
            {
                AnsiTextWriter.Attach();
            }

            context.SetVirtualConsoleProvider(() => new VirtualConsoleProvider(Console.In, Console.Out, Console.Error));
            context.DefaultPager = DefaultPager.Value;

            context.SetEnvironmentVariables(SettingsContainer.VarSettings.EnvironmentVariables);
        }
        /// <summary>
        /// Popupates the main application context with effective settings for a console application
        /// </summary>
        public MainApplicationContext CreateConsoleApplicationContext()
        {
            Console.OutputEncoding = OutputEncoding.Value;
            if (AnsiTerminalEmulation.Value)
            {
                AnsiTextWriter.Attach();
            }

            var context = new MainApplicationContext()
            {
                IsAtty       = IsAtty.Value,
                TimeZone     = TimeZoneId.Value,
                DefaultPager = DefaultPager.Value
            };

            context.SetEnvironmentVariables(SettingsContainer.VarSettings.EnvironmentVariables);
            return(context);
        }
Example #3
0
        static void Main(string[] args)
        {
            // System.Diagnostics.Debugger.Launch(); // This debugging option might be useful in case of troubleshooting of NLTest issues

            var main = new Main();

            var config = new AppConfiguration();

            MainApplicationContext.Current.IsAtty     = config.IsAtty;
            MainApplicationContext.Current.TimeZoneId = config.TimeZoneId;
            Console.OutputEncoding = config.OutputEncoding;
            if (config.IsAnsiTerminalEmulation)
            {
                AnsiTextWriter.Attach();
            }

            var argString = GetCommandLine(); // This way is prefferable because of double quotas that are missed by using args
            var envs      = Environment.GetEnvironmentVariables().Cast <DictionaryEntry>().ToDictionary(d => d.Key.ToString(), d => d.Value.ToString());

            Environment.ExitCode = main.Execute(argString, envs, Console.In, Console.Out, Console.Error);
        }