public Program() { program = this; try { // Initialize Modules. _grid = new Grid(); _logger = new Logger(Logger.LogLevel.INFO, HelloProgram.TAG, false); _disk = new Disk(); _configuration = new Configuration(); _command = new Command(); _timer = new Timer(); _encryption = new Encryption(); // Writing a custom encyption algorithm? Test it here! //throw new Exception($"Encyption/Decryption algorithm successful?: {_encryption.test("awesome!")}"); // Initialize custom program(s). _customProgram = new HelloProgram(); // Manage configurations. this.WriteDefaultConfigurations(); Load(); } catch (Exception ex) { Program.program.Echo($"**INIT ERROR**\n{ex}"); } }
//Search through ProcDataGrid to find corresponding ConfigItem private ConfigItem GetConfigFromCustomProgram(CustomProgram program) { foreach (var procSourceItem in ProcessDataGrid.ItemsSource) { if (program.Equals(procSourceItem)) { return(procSourceItem as ConfigItem); } } //Return null on failure return(null); }
/// <summary> /// Attempts to load any saved modules. If loading fails, they will simply default to new instances. /// </summary> public void Load() { try { Command command = Program.program._disk.ReadClass <Command>(); if (command != null) { Program.program._command = command; } CustomProgram program = Program.program._disk.ReadClass <HelloProgram>(); if (program != null) { Program.program._customProgram = program; } } catch (Exception ex) { Program.program.Echo($"**LOAD ERROR**\n{ex}"); } }