diff --git a/TIASshot/Config.cs b/TIASshot/Config.cs
index 9431682..0ab0e24 100644
--- a/TIASshot/Config.cs
+++ b/TIASshot/Config.cs
@@ -46,14 +46,14 @@
///
///
public static float GetFloat(string param) {
- float value = 0.0f;
XmlNode node = doc.SelectSingleNode($"//Config/{param}");
if (node == null) throw new ArgumentException($"Parameter '{param}' not found in config file.");
- if (node != null && float.TryParse(node.InnerText, out float result)) {
- value = result;
+ if (!float.TryParse(node.InnerText, System.Globalization.NumberStyles.Float,
+ System.Globalization.CultureInfo.InvariantCulture, out float result)) {
+ throw new ArgumentException($"Parameter '{param}' value '{node.InnerText}' is not a valid float.");
}
- return value;
+ return result;
}
///
@@ -62,14 +62,14 @@
///
///
public static int GetInt(string param) {
- int value = 0;
XmlNode node = doc.SelectSingleNode($"//Config/{param}");
if (node == null) throw new ArgumentException($"Parameter '{param}' not found in config file.");
- if (node != null && int.TryParse(node.InnerText, out int result)) {
- value = result;
+ if (!int.TryParse(node.InnerText, System.Globalization.NumberStyles.Integer,
+ System.Globalization.CultureInfo.InvariantCulture, out int result)) {
+ throw new ArgumentException($"Parameter '{param}' value '{node.InnerText}' is not a valid int.");
}
- return value;
+ return result;
}
///