Added setting 'TheMaxStructuresInRange' to command line.

Changed to int data type.
This commit is contained in:
Brett Hewitson 2021-11-23 16:56:54 +10:00
parent 9d5dafaed6
commit 99438f54e3
5 changed files with 56 additions and 25 deletions

View file

@ -57,28 +57,38 @@ namespace ServerManagerTool.Common.Utils
{
if (property.PropertyType == typeof(bool) || property.PropertyType == typeof(bool?))
{
bool boolValue;
bool.TryParse(value, out boolValue);
bool.TryParse(value, out bool boolValue);
property.SetValue(obj, boolValue);
}
else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(int?))
{
int intValue;
int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue);
string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator;
var tempValue = value;
if (tempValue.Contains(decimalSeparator))
{
tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator));
}
int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue);
property.SetValue(obj, intValue);
}
else if (property.PropertyType == typeof(float) || property.PropertyType == typeof(float?))
{
var tempValue = value.Replace("f", "");
float floatValue;
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue);
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue);
property.SetValue(obj, floatValue);
}
else if (property.PropertyType == typeof(NullableValue<int>))
{
int intValue;
int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue);
string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator;
var tempValue = value;
if (tempValue.Contains(decimalSeparator))
{
tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator));
}
int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue);
var field = property.GetValue(obj) as NullableValue<int>;
property.SetValue(obj, field.SetValue(true, intValue));
}
@ -86,8 +96,7 @@ namespace ServerManagerTool.Common.Utils
{
var tempValue = value.Replace("f", "");
float floatValue;
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue);
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue);
var field = property.GetValue(obj) as NullableValue<float>;
property.SetValue(obj, field.SetValue(true, floatValue));
}
@ -121,8 +130,14 @@ namespace ServerManagerTool.Common.Utils
}
if (property.PropertyType == typeof(int) || property.PropertyType == typeof(int?))
{
int intValue;
int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue);
string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator;
var tempValue = value;
if (tempValue.Contains(decimalSeparator))
{
tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator));
}
int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue);
property.SetValue(obj, intValue);
return true;
}
@ -130,15 +145,20 @@ namespace ServerManagerTool.Common.Utils
{
var tempValue = value.Replace("f", "");
float floatValue;
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue);
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue);
property.SetValue(obj, floatValue);
return true;
}
if (property.PropertyType == typeof(NullableValue<int>))
{
int intValue;
int.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out intValue);
string decimalSeparator = CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE).NumberFormat.NumberDecimalSeparator;
var tempValue = value;
if (tempValue.Contains(decimalSeparator))
{
tempValue = tempValue.Substring(0, tempValue.IndexOf(decimalSeparator));
}
int.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out int intValue);
var field = property.GetValue(obj) as NullableValue<int>;
property.SetValue(obj, field.SetValue(true, intValue));
return true;
@ -147,8 +167,7 @@ namespace ServerManagerTool.Common.Utils
{
var tempValue = value.Replace("f", "");
float floatValue;
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out floatValue);
float.TryParse(tempValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.GetCultureInfo(DEFAULT_CULTURE_CODE), out float floatValue);
var field = property.GetValue(obj) as NullableValue<float>;
property.SetValue(obj, field.SetValue(true, floatValue));
return true;