in src/FabActUtil/CommandLineParser/CommandLineArgumentParser.cs [695:765]
private bool ParseValue(Type type, string stringData, out object value)
{
// null is only valid for bool variables
// empty string is never valid
if ((stringData != null || type == typeof(bool)) && (stringData == null || stringData.Length > 0))
{
try
{
if (type == typeof(string))
{
value = stringData;
return true;
}
else if (type == typeof(bool))
{
if (stringData == null || stringData == "+")
{
value = true;
return true;
}
else if (stringData == "-")
{
value = false;
return true;
}
}
else if (type == typeof(int))
{
if (stringData != null)
{
value = int.Parse(stringData);
return true;
}
value = 0;
return false;
}
else if (type == typeof(uint))
{
if (stringData != null)
{
value = int.Parse(stringData);
return true;
}
value = 0;
return false;
}
else
{
Debug.Assert(type.IsEnum, "The type must be an enumeration.");
if (stringData != null)
{
value = Enum.Parse(type, stringData, true);
return true;
}
value = 0;
return false;
}
}
catch
{
// catch parse errors
}
}
this.ReportBadArgumentValue(stringData);
value = null;
return false;
}