public BasilXViewer(BasilXContext pContext) { _context = pContext; }
public void Start(string[] args) { // Create an application level 'context' to pass around. // This is not for global variables but for utilities needed by all (logging, parameters, ...) _context = new BasilXContext() { log = new LoggerConsole(), version = Assembly.GetExecutingAssembly().GetName().Version.ToString(), // A command is added to the pre-build events that generates BuildDate resource: // echo %date% %time% > "$(ProjectDir)\Resources\BuildDate.txt" buildDate = Properties.Resources.BuildDate.Trim(), // A command is added to the pre-build events that generates last commit resource: // git rev-parse HEAD > "$(ProjectDir)\Resources\GitCommit.txt" gitCommit = Properties.Resources.GitCommit.Trim(), // Application level shutdown flag cancellation = new CancellationTokenSource() }; _context.parms = new Params(_context); // A single parameter of '--help' outputs the invocation parameters if (args.Length > 0 && args[0] == "--help") { System.Console.Write(Invocation()); return; } // 'Params' initializes to default values. // Override default values with command line parameters. try { // Note that trailing parameters will be put into "Extras" parameter _context.parms.MergeCommandLine(args, null, "Extras"); } catch (Exception e) { _context.log.ErrorFormat("ERROR: bad parameters: " + e.Message); _context.log.ErrorFormat(Invocation()); return; } if (_context.parms.P <bool>(Params.PVerbose)) { _context.log.SetVerbose(_context.parms.P <bool>(Params.PVerbose)); } if (!_context.parms.P <bool>(Params.PQuiet)) { System.Console.WriteLine(_logHeader + " v" + _context.version + " built " + _context.buildDate + " commit " + _context.gitCommit ); } // Start the graphics system var viewer = new BasilXViewer(_context); viewer.Start(); // Start the communication system var comm = new BasilXComm(_context); comm.Start(); while (!_context.cancellation.IsCancellationRequested) { Thread.Sleep(100); } }
public BasilXComm(BasilXContext pContext) { _context = pContext; }