Пример #1
0
        static async Task Main(string[] args)
        {
            ConsoleTraceListener consoleTraceListener = new ConsoleTraceListener();

            consoleTraceListener.Name = "Main output";
            Trace.Listeners.Add(consoleTraceListener);

            try
            {
                //TODO... arg error checking required.

                Trace.WriteLine($"Starting NutKitDotNet on {args[0]}:{args[1]}");
                var address = args[0];
                var port    = Convert.ToInt32(args[1]);

                using var connection = new Connection(address, port);
                Controller controller = new Controller(connection);
                await controller.Process().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine($"Exception Details: \n {ex.StackTrace}");
            }
            finally
            {
                Trace.Flush();
                Trace.Listeners.Remove(consoleTraceListener);
                consoleTraceListener.Close();
                Trace.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// Ecrit dans la console le message
        /// </summary>
        /// <param name="message">message</param>
        public static void WriteInConsole(string message)
        {
            ConsoleTraceListener consoleTracer;

            consoleTracer = new ConsoleTraceListener(true);
            consoleTracer.WriteLine(message);
            consoleTracer.Close();
        }
Пример #3
0
        static void Main(string[] args)
        {
            /*
             * using (var reader = new StreamReader( @"s:\source\repos\Robotron_2084\VirtuRoX\tmp\MemoryOperations.csv" ))
             * using (var csv = new CsvReader( reader, Thread.CurrentThread.CurrentCulture )) {
             *  _records = csv.GetRecords<RecordedMemoryOperation>().ToList();
             * }
             *
             * var bla = _records.GroupBy( info => info.Address ).Select( group => new Tuple<int, int>( group.Key, group.Count() ) ).OrderBy( x => x.Item1 );
             * _dict = bla.ToDictionary( x => x.Item1 );
             * Console.WriteLine( _dict.Count );
             * object[,] res = GetReadCounts( 224, 32 );
             * Console.WriteLine( _dict.ToString() );
             * return;
             */
            /*
             * AsmLinesWindow wnd1 = new AsmLinesWindow();
             * wnd1.ShowDialog();
             * return;
             */

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed <Options>(o => {
                ConsoleTraceListener tracer = new ConsoleTraceListener();
                Trace.Listeners.Add(tracer);
                Trace.WriteLine("Main() start");

                AsmReader reader = new AsmReader(@"s:\source\repos\Robotron_2084\Disassemblies\Robotron (Apple).asm");
                //reader.Test1();

                Trace.WriteLine($"Running workbench{(o.Breakpoints ? "with" : "without")} breakpoints: -b {o.Breakpoints}");

                using (_machineOperator = new MachineOperator()) {
                    if (o.Breakpoints)
                    {
                        // _machineOperator.OnPaused += MachineOperator_OnPaused;
                        _workbench = new Workbench(_machineOperator, o);
                    }
                    else
                    {
                        _machineOperator.OnLoaded += ( MachineOperator mo ) => mo.LoadStateFromFile(mo.BlaBin);
                    }

                    //Form1 frm = new Form1();
                    //frm.Populate();
                    //frm.Show();

                    _machineOperator.ShowDialog();
                }


                Trace.WriteLine("Main() end");
                Trace.Flush();
                Trace.Listeners.Remove(tracer);
                tracer.Close();
                Trace.Close();
            });
        }
Пример #4
0
 public static void NopClose()
 {
     using (var listener = new ConsoleTraceListener())
     {
         listener.Close();
         Assert.NotNull(listener.Writer);
         Assert.Equal(Console.Out, listener.Writer);
     }
 }
Пример #5
0
    /// <summary>
    /// Stops and disposes of the logging service
    /// </summary>
    public override void RemoveListener()
    {
        Trace.Listeners.Remove(twtl);
        Trace.Listeners.Remove(ctl);
        Trace.Close();

        if (ctl != null)
        {
            ctl.Close();

            ctl.Dispose();
        }

        if (twtl != null)
        {
            twtl.Close();

            twtl.Dispose();
        }
    }
Пример #6
0
        public static void Main(string[] args)
        {
            var    version   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            bool   verbose   = false;
            bool   auto      = false;
            bool   force     = false;
            string folder    = string.Empty;
            string file      = string.Empty;
            string reference = string.Empty;

            //var services = ConfigureServices();
            //var serviceProvider = services.BuildServiceProvider();

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower())
                {
                case "-import": operation = Operation.Import; break;

                case "-hash": operation = Operation.Hash; break;

                case "-rehash": operation = Operation.Hash; force = true; break;

                case "-verify": operation = Operation.Verify; break;

                case "-diff": operation = Operation.Diff; break;

                case "-verbose": verbose = true; break;

                case "-auto": auto = true; break;

                case "-folder": folder = args[i + 1]; break;

                case "-file": file = args[i + 1]; break;

                case "-reference": reference = args[i + 1]; break;
                }
            }

            using (ConsoleTraceListener consoleTracer = new ConsoleTraceListener())
            {
                if (verbose)
                {
                    Trace.Listeners.Add(consoleTracer);
                }
                try
                {
                    switch (operation)
                    {
                    case Operation.Import:
                        Common.Msg($"FDR Tools {version} - Import", titleColor);
                        var appConfig = LoadAppConfig();
                        Import.ImportWizard(appConfig.ImportConfigs, auto);
                        break;

                    case Operation.Hash:
                        Common.Msg($"FDR Tools {version} - Hash", titleColor);
                        if (!Common.IsFolderValid(folder))
                        {
                            return;
                        }
                        Verify.HashFolder(new DirectoryInfo(Path.GetFullPath(folder)), force);
                        break;

                    case Operation.Verify:
                        Common.Msg($"FDR Tools {version} - Verify", titleColor);
                        if (!Common.IsFolderValid(folder))
                        {
                            return;
                        }
                        Verify.VerifyFolder(new DirectoryInfo(Path.GetFullPath(folder)));
                        break;

                    case Operation.Diff:
                        Common.Msg($"FDR Tools {version} - Diff", titleColor);
                        if (!Common.IsFolderValid(folder))
                        {
                            return;
                        }
                        if (!Common.IsFolderValid(reference))
                        {
                            return;
                        }
                        Verify.DiffFolder(new DirectoryInfo(Path.GetFullPath(folder)), new DirectoryInfo(Path.GetFullPath(reference)));
                        break;

                    default:
                        DisplayHelp(version);
                        break;
                    }
                }
                finally
                {
                    Trace.Flush();
                    Trace.Listeners.Remove(consoleTracer);
                    consoleTracer.Close();
                }
            }
        }