// TEMP - REMOVE public void performConfigurationRetrieve() { if (cE > 1) { m_log.Error("[CONFIG]: READING CONFIGURATION COUT: " + cE.ToString()); } configurationPlugin = LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); if (loadFunction == null) { m_log.Error("[CONFIG]: Load Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } if (resultFunction == null) { m_log.Error("[CONFIG]: Result Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } //m_log.Debug("[CONFIG]: Calling Configuration Load Function..."); loadFunction(); if (configurationOptions.Count <= 0) { m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions + "'. Refusing to continue configuration."); return; } bool useFile = true; if (configurationPlugin == null) { m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!"); return; } if (!String.IsNullOrWhiteSpace(configurationFilename)) { configurationPlugin.SetFileName(configurationFilename); try { configurationPlugin.LoadData(); useFile = true; } catch (XmlException e) { m_log.WarnFormat("[CONFIG]: Not using {0}: {1}", configurationFilename, e.Message.ToString()); //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString()); useFile = false; } } else { if (configurationFromXMLNode != null) { m_log.Info("[CONFIG]: Loading from XML Node, will not save to the file"); configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); } m_log.Info("[CONFIG]: XML Configuration Filename is not valid; will not save to the file."); useFile = false; } foreach (ConfigurationOption configOption in configurationOptions) { bool convertSuccess = false; object return_result = null; string errorMessage = String.Empty; bool ignoreNextFromConfig = false; while (convertSuccess == false) { string console_result = String.Empty; string attribute = null; if (useFile || configurationFromXMLNode != null) { if (!ignoreNextFromConfig) { attribute = configurationPlugin.GetAttribute(configOption.configurationKey); } else { ignoreNextFromConfig = false; } } if (attribute == null) { if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false) { console_result = configOption.configurationDefault; } else { if ((configOption.shouldIBeAsked != null && configOption.shouldIBeAsked(configOption.configurationKey)) || configOption.shouldIBeAsked == null) { if (!String.IsNullOrWhiteSpace(configurationDescription)) { console_result = MainConsole.Instance.CmdPrompt( configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); } else { console_result = MainConsole.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); } } else { //Dont Ask! Just use default console_result = configOption.configurationDefault; } } } else { console_result = attribute; } // If the first character of a multicharacter string is a "$", assume it's the name of an environment variable and substitute with the value of that variable. if (console_result.StartsWith("$", StringComparison.InvariantCulture) && console_result.Length > 1) { // Using a second $ to be an escape character was experimented with, but that would require modifying the write process to re-apply the escape character. Over-all escapes seem too fragile, and the below code handles it cleanly. If the admin wants to use a value that collides with an environment variable, then the admin can make sure to unset it first. var env_var_key = console_result.Substring(1); var env_var_value = Environment.GetEnvironmentVariable(env_var_key); if (env_var_value != null) { // Log the use of an environment variable just in case someone didn't expect it. m_log.Info($"[CONFIG]: Parameter [{configOption.configurationKey}] started with '$'. Value replaced with environment variable '{env_var_key}' value '{env_var_value}'."); console_result = env_var_value; } else { // Unless there is no such variable, in which case just move on with the original and let the user know that happened. m_log.Warn($"[CONFIG]: Parameter [{configOption.configurationKey}] started with '$', however there was no environment variable found with the name '{env_var_key}'."); } } switch (configOption.configurationType) { case ConfigurationOption.ConfigurationTypes.TYPE_STRING: return_result = console_result; convertSuccess = true; break; case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: if (!String.IsNullOrEmpty(console_result)) { return_result = console_result; convertSuccess = true; } errorMessage = "a string that is not empty"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: bool boolResult; if (Boolean.TryParse(console_result, out boolResult)) { convertSuccess = true; return_result = boolResult; } errorMessage = "'true' or 'false' (Boolean)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: byte byteResult; if (Byte.TryParse(console_result, out byteResult)) { convertSuccess = true; return_result = byteResult; } errorMessage = "a byte (Byte)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: char charResult; if (Char.TryParse(console_result, out charResult)) { convertSuccess = true; return_result = charResult; } errorMessage = "a character (Char)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT16: short shortResult; if (Int16.TryParse(console_result, out shortResult)) { convertSuccess = true; return_result = shortResult; } errorMessage = "a signed 32 bit integer (short)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT32: int intResult; if (Int32.TryParse(console_result, out intResult)) { convertSuccess = true; return_result = intResult; } errorMessage = "a signed 32 bit integer (int)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT64: long longResult; if (Int64.TryParse(console_result, out longResult)) { convertSuccess = true; return_result = longResult; } errorMessage = "a signed 32 bit integer (long)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: IPAddress ipAddressResult; if (IPAddress.TryParse(console_result, out ipAddressResult)) { convertSuccess = true; return_result = ipAddressResult; } errorMessage = "an IP Address (IPAddress)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID: UUID uuidResult; if (UUID.TryParse(console_result, out uuidResult)) { convertSuccess = true; return_result = uuidResult; } errorMessage = "a UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE: UUID uuidResult2; if (UUID.TryParse(console_result, out uuidResult2)) { convertSuccess = true; if (uuidResult2 == UUID.Zero) { uuidResult2 = UUID.Random(); } return_result = uuidResult2; } errorMessage = "a non-null UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_Vector3: Vector3 vectorResult; if (Vector3.TryParse(console_result, out vectorResult)) { convertSuccess = true; return_result = vectorResult; } errorMessage = "a vector (Vector3)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: ushort ushortResult; if (UInt16.TryParse(console_result, out ushortResult)) { convertSuccess = true; return_result = ushortResult; } errorMessage = "an unsigned 16 bit integer (ushort)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: uint uintResult; if (UInt32.TryParse(console_result, out uintResult)) { convertSuccess = true; return_result = uintResult; } errorMessage = "an unsigned 32 bit integer (uint)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: ulong ulongResult; if (UInt64.TryParse(console_result, out ulongResult)) { convertSuccess = true; return_result = ulongResult; } errorMessage = "an unsigned 64 bit integer (ulong)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: float floatResult; if ( float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out floatResult)) { convertSuccess = true; return_result = floatResult; } errorMessage = "a single-precision floating point number (float)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: double doubleResult; if ( Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out doubleResult)) { convertSuccess = true; return_result = doubleResult; } errorMessage = "an double-precision floating point number (double)"; break; } if (convertSuccess) { if (useFile) { configurationPlugin.SetAttribute(configOption.configurationKey, console_result); } if (!resultFunction(configOption.configurationKey, return_result)) { m_log.Info( "[CONFIG]: The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; } } else { if (configOption.configurationUseDefaultNoPrompt) { m_log.Error(string.Format( "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); convertSuccess = true; } else { m_log.Warn(string.Format( "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); ignoreNextFromConfig = true; } } } } if (useFile) { configurationPlugin.Commit(); configurationPlugin.Close(); } }
// TEMP - REMOVE public void performConfigurationRetrieve() { if (cE > 1) m_log.Error("READING CONFIGURATION COUT: " + cE.ToString()); configurationPlugin = LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); if (loadFunction == null) { m_log.Error("Load Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } if (resultFunction == null) { m_log.Error("Result Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } //m_log.Debug("[CONFIG]: Calling Configuration Load Function..."); loadFunction(); if (configurationOptions.Count <= 0) { m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions + "'. Refusing to continue configuration."); return; } bool useFile = true; if (configurationPlugin == null) { m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!"); return; } if (configurationFilename.Trim() != String.Empty) { configurationPlugin.SetFileName(configurationFilename); try { configurationPlugin.LoadData(); useFile = true; } catch (XmlException e) { m_log.WarnFormat("[CONFIG] Not using {0}: {1}", configurationFilename, e.Message.ToString()); //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString()); useFile = false; } } else { if (configurationFromXMLNode != null) { m_log.Info("Loading from XML Node, will not save to the file"); configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); } m_log.Info("XML Configuration Filename is not valid; will not save to the file."); useFile = false; } foreach (ConfigurationOption configOption in configurationOptions) { bool convertSuccess = false; object return_result = null; string errorMessage = String.Empty; bool ignoreNextFromConfig = false; while (convertSuccess == false) { string console_result = String.Empty; string attribute = null; if (useFile || configurationFromXMLNode != null) { if (!ignoreNextFromConfig) { attribute = configurationPlugin.GetAttribute(configOption.configurationKey); } else { ignoreNextFromConfig = false; } } if (attribute == null) { if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false) { console_result = configOption.configurationDefault; } else { if ((configOption.shouldIBeAsked != null && configOption.shouldIBeAsked(configOption.configurationKey)) || configOption.shouldIBeAsked == null) { if (configurationDescription.Trim() != String.Empty) { console_result = MainConsole.Instance.CmdPrompt( configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); } else { console_result = MainConsole.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); } } else { //Dont Ask! Just use default console_result = configOption.configurationDefault; } } } else { console_result = attribute; } // if the first character is a "$", assume it's the name // of an environment variable and substitute with the value of that variable if (console_result.StartsWith("$")) console_result = Environment.GetEnvironmentVariable(console_result.Substring(1)); switch (configOption.configurationType) { case ConfigurationOption.ConfigurationTypes.TYPE_STRING: return_result = console_result; convertSuccess = true; break; case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: if (console_result.Length > 0) { return_result = console_result; convertSuccess = true; } errorMessage = "a string that is not empty"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: bool boolResult; if (Boolean.TryParse(console_result, out boolResult)) { convertSuccess = true; return_result = boolResult; } errorMessage = "'true' or 'false' (Boolean)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: byte byteResult; if (Byte.TryParse(console_result, out byteResult)) { convertSuccess = true; return_result = byteResult; } errorMessage = "a byte (Byte)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: char charResult; if (Char.TryParse(console_result, out charResult)) { convertSuccess = true; return_result = charResult; } errorMessage = "a character (Char)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT16: short shortResult; if (Int16.TryParse(console_result, out shortResult)) { convertSuccess = true; return_result = shortResult; } errorMessage = "a signed 32 bit integer (short)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT32: int intResult; if (Int32.TryParse(console_result, out intResult)) { convertSuccess = true; return_result = intResult; } errorMessage = "a signed 32 bit integer (int)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT64: long longResult; if (Int64.TryParse(console_result, out longResult)) { convertSuccess = true; return_result = longResult; } errorMessage = "a signed 32 bit integer (long)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: IPAddress ipAddressResult; if (IPAddress.TryParse(console_result, out ipAddressResult)) { convertSuccess = true; return_result = ipAddressResult; } errorMessage = "an IP Address (IPAddress)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID: UUID uuidResult; if (UUID.TryParse(console_result, out uuidResult)) { convertSuccess = true; return_result = uuidResult; } errorMessage = "a UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE: UUID uuidResult2; if (UUID.TryParse(console_result, out uuidResult2)) { convertSuccess = true; if (uuidResult2 == UUID.Zero) uuidResult2 = UUID.Random(); return_result = uuidResult2; } errorMessage = "a non-null UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_Vector3: Vector3 vectorResult; if (Vector3.TryParse(console_result, out vectorResult)) { convertSuccess = true; return_result = vectorResult; } errorMessage = "a vector (Vector3)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: ushort ushortResult; if (UInt16.TryParse(console_result, out ushortResult)) { convertSuccess = true; return_result = ushortResult; } errorMessage = "an unsigned 16 bit integer (ushort)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: uint uintResult; if (UInt32.TryParse(console_result, out uintResult)) { convertSuccess = true; return_result = uintResult; } errorMessage = "an unsigned 32 bit integer (uint)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: ulong ulongResult; if (UInt64.TryParse(console_result, out ulongResult)) { convertSuccess = true; return_result = ulongResult; } errorMessage = "an unsigned 64 bit integer (ulong)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: float floatResult; if ( float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out floatResult)) { convertSuccess = true; return_result = floatResult; } errorMessage = "a single-precision floating point number (float)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: double doubleResult; if ( Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out doubleResult)) { convertSuccess = true; return_result = doubleResult; } errorMessage = "an double-precision floating point number (double)"; break; } if (convertSuccess) { if (useFile) { configurationPlugin.SetAttribute(configOption.configurationKey, console_result); } if (!resultFunction(configOption.configurationKey, return_result)) { m_log.Info( "The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; } } else { if (configOption.configurationUseDefaultNoPrompt) { m_log.Error(string.Format( "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); convertSuccess = true; } else { m_log.Warn(string.Format( "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); ignoreNextFromConfig = true; } } } } if (useFile) { configurationPlugin.Commit(); configurationPlugin.Close(); } }
// TEMP - REMOVE public void performConfigurationRetrieve() { if (cE > 1) { m_log.Error("READING CONFIGURATION COUT: " + cE.ToString()); } configurationPlugin = LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); if (loadFunction == null) { m_log.Error("Load Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } if (resultFunction == null) { m_log.Error("Result Function for '" + configurationDescription + "' is null. Refusing to run configuration."); return; } //m_log.Debug("[CONFIG]: Calling Configuration Load Function..."); loadFunction(); if (configurationOptions.Count <= 0) { m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions + "'. Refusing to continue configuration."); return; } bool useFile = true; if (configurationPlugin == null) { m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!"); return; } if (configurationFilename.Trim() != String.Empty) { configurationPlugin.SetFileName(configurationFilename); try { configurationPlugin.LoadData(); useFile = true; } catch (XmlException e) { m_log.WarnFormat("[CONFIG] Not using {0}: {1}", configurationFilename, e.Message.ToString()); //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString()); useFile = false; } } else { if (configurationFromXMLNode != null) { m_log.Info("Loading from XML Node, will not save to the file"); configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); } m_log.Info("XML Configuration Filename is not valid; will not save to the file."); useFile = false; } foreach (ConfigurationOption configOption in configurationOptions) { bool convertSuccess = false; object return_result = null; string errorMessage = String.Empty; bool ignoreNextFromConfig = false; while (convertSuccess == false) { string console_result = String.Empty; string attribute = null; if (useFile || configurationFromXMLNode != null) { if (!ignoreNextFromConfig) { attribute = configurationPlugin.GetAttribute(configOption.configurationKey); } else { ignoreNextFromConfig = false; } } if (attribute == null) { if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false) { console_result = configOption.configurationDefault; } else { if ((configOption.shouldIBeAsked != null && configOption.shouldIBeAsked(configOption.configurationKey)) || configOption.shouldIBeAsked == null) { if (configurationDescription.Trim() != String.Empty) { console_result = MainConsole.Instance.Prompt( configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); } else { console_result = MainConsole.Instance.Prompt(configOption.configurationQuestion, configOption.configurationDefault); } } else { //Dont Ask! Just use default console_result = configOption.configurationDefault; } } } else { console_result = attribute; } // if the first character is a "$", assume it's the name // of an environment variable and substitute with the value of that variable if (console_result.StartsWith("$")) { console_result = Environment.GetEnvironmentVariable(console_result.Substring(1)); } switch (configOption.configurationType) { case ConfigurationOption.ConfigurationTypes.TYPE_STRING: return_result = console_result; convertSuccess = true; break; case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: if (console_result.Length > 0) { return_result = console_result; convertSuccess = true; } errorMessage = "a string that is not empty"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: bool boolResult; if (Boolean.TryParse(console_result, out boolResult)) { convertSuccess = true; return_result = boolResult; } errorMessage = "'true' or 'false' (Boolean)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: byte byteResult; if (Byte.TryParse(console_result, out byteResult)) { convertSuccess = true; return_result = byteResult; } errorMessage = "a byte (Byte)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: char charResult; if (Char.TryParse(console_result, out charResult)) { convertSuccess = true; return_result = charResult; } errorMessage = "a character (Char)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT16: short shortResult; if (Int16.TryParse(console_result, out shortResult)) { convertSuccess = true; return_result = shortResult; } errorMessage = "a signed 32 bit integer (short)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT32: int intResult; if (Int32.TryParse(console_result, out intResult)) { convertSuccess = true; return_result = intResult; } errorMessage = "a signed 32 bit integer (int)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_INT64: long longResult; if (Int64.TryParse(console_result, out longResult)) { convertSuccess = true; return_result = longResult; } errorMessage = "a signed 32 bit integer (long)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: IPAddress ipAddressResult; if (IPAddress.TryParse(console_result, out ipAddressResult)) { convertSuccess = true; return_result = ipAddressResult; } errorMessage = "an IP Address (IPAddress)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID: UUID uuidResult; if (UUID.TryParse(console_result, out uuidResult)) { convertSuccess = true; return_result = uuidResult; } errorMessage = "a UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE: UUID uuidResult2; if (UUID.TryParse(console_result, out uuidResult2)) { convertSuccess = true; if (uuidResult2 == UUID.Zero) { uuidResult2 = UUID.Random(); } return_result = uuidResult2; } errorMessage = "a non-null UUID (UUID)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_Vector3: Vector3 vectorResult; if (Vector3.TryParse(console_result, out vectorResult)) { convertSuccess = true; return_result = vectorResult; } errorMessage = "a vector (Vector3)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: ushort ushortResult; if (UInt16.TryParse(console_result, out ushortResult)) { convertSuccess = true; return_result = ushortResult; } errorMessage = "an unsigned 16 bit integer (ushort)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: uint uintResult; if (UInt32.TryParse(console_result, out uintResult)) { convertSuccess = true; return_result = uintResult; } errorMessage = "an unsigned 32 bit integer (uint)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: ulong ulongResult; if (UInt64.TryParse(console_result, out ulongResult)) { convertSuccess = true; return_result = ulongResult; } errorMessage = "an unsigned 64 bit integer (ulong)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: float floatResult; if ( float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out floatResult)) { convertSuccess = true; return_result = floatResult; } errorMessage = "a single-precision floating point number (float)"; break; case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: double doubleResult; if ( Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, out doubleResult)) { convertSuccess = true; return_result = doubleResult; } errorMessage = "an double-precision floating point number (double)"; break; } if (convertSuccess) { if (useFile) { configurationPlugin.SetAttribute(configOption.configurationKey, console_result); } if (!resultFunction(configOption.configurationKey, return_result)) { m_log.Info( "The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; } } else { if (configOption.configurationUseDefaultNoPrompt) { m_log.Error(string.Format( "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); convertSuccess = true; } else { m_log.Warn(string.Format( "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); ignoreNextFromConfig = true; } } } } if (useFile) { configurationPlugin.Commit(); configurationPlugin.Close(); } }