private static ActionOnDevice laterSetSettings() { // Read the entire file before connecting to the device. String filename = nextArgument(); List <String> warnings = new List <string>(); SmcSettings settings = SettingsFile.load(filename, warnings); return(delegate(Smc device) { Smc.fixSettings(settings, warnings, device.productId, device.getFirmwareVersion()); // Handle any warnings. if (warnings.Count != 0) { Console.WriteLine("There were problems with the settings file:"); foreach (String warning in warnings) { Console.WriteLine(" " + warning); } if (forceOption) { Console.WriteLine("The -f option is selected, so the settings will be applied anyway."); } else { throw new Exception("Aborted because of problems with settings file.\n" + "Use the -f option to override and apply settings anyway."); } } device.setSmcSettings(settings); }); }
private static ActionOnDevice laterConfigure() { // Read the entire file before connecting to the device. String filename = nextArgument(); List <String> warnings = new List <string>(); SmcSettings settings = SettingsFile.load(filename, warnings, 0); Smc.fixSettings(settings, warnings, 0); // Handle any warnings. if (warnings.Count != 0) { Console.WriteLine("There were problems with the settings file:"); foreach (String warning in warnings) { Console.WriteLine(" " + warning); } if (forceOption) { Console.WriteLine("The -f option is selected, so the settings will be applied anyway."); } else { throw new Exception("Aborted because of problems with settings file.\nUse the -f option to override and apply settings anyway."); } } // Return a delegate function that will get executed later after all // the command line arguments have been processed. return(delegate(Smc device) { // This is the line that actually applies the settings to the device. device.setSmcSettings(settings); }); }