/// <summary> /// Parses a value from a <see cref="string"/>. /// </summary> /// <param name="str">The <see cref="string"/> value.</param> /// <param name="result">The resulting value.</param> /// <returns><c>true</c> where <paramref name="str"/> was converted sucessfully; otherwise, <c>false</c>.</returns> public bool TryParse(string str, out bool result) { result = false; if (FalseValues.Contains(str, StringComparer)) { return(true); } if (!TrueValues.Contains(str, StringComparer)) { return(false); } result = true; return(true); }
private bool?ParseNullableBoolean(string from) { if (bool.TryParse(from, out var value)) { return(value); } if (TrueValues.Contains(from)) { return(true); } if (FalseValues.Contains(from)) { return(false); } return(null); }
public override string ToString() { return($"'{TrueValues.First()}' or '{FalseValues.First()}'"); }
static bool?Parse(string value) { return(TrueValues.Contains(value) ? true : (FalseValues.Contains(value) ? false : (bool?)null)); }