The MSDN article is confusing, because it initially says that Boolean.TryParse compares the value to the strings "True" and "False", but then in the remarks it says "
The value parameter can be preceded or followed by white space. The comparison is ordinal and case-insensitive.", and in the example it correctly parses "true" and " true ":
http://msdn.microsoft.com/en-us/library/system.boolean.tryparse(v=vs.110).aspxI just tested it myself, and found that it does ignore leading/trailing whitespace and case, so it'll also correctly parse " true ", "false\n", "TRUE", "FALSE", "tRuE" and "FaLsE".
void test() {
{
string[] values = { null, System.String.Empty, "True", "False",
"true", "false", " true ", "false\n", "TRUE", "FALSE",
"tRuE", "FaLsE", "T", "F", "yes", "no", "0",
"1", "-1", "string" };
foreach (var value in values) {
bool flag;
if (System.Boolean.TryParse(value, out flag))
Debug.Log("\"" + value + "\" --> " + flag.ToString());
else
Debug.Log("Can't parse \"" + (value == null ? "<null>" : value) + "\"");
}
}
}
also, in your current implementation, "True" resolves as
false anyway, because ResolveValue only compares the value to "true" and "false", and doesn't pass it on to SetValue as a bool because ResolveValue is called with a type of "null". I recommend adding
else { // is it a boolean?
bool b;
if (bool.TryParse(line, out b)) {
mValue = b;
return true;
}
}
at 693, and removing the string comparisons at 652.