2019-08-23 11:56:54 -07:00
|
|
|
namespace System
|
|
|
|
{
|
|
|
|
struct Boolean : bool, IHashable
|
|
|
|
{
|
2020-05-26 20:56:19 +01:00
|
|
|
//
|
|
|
|
// Public Constants
|
|
|
|
//
|
|
|
|
|
|
|
|
// The public string representation of true.
|
|
|
|
public const String TrueString = "True";
|
|
|
|
|
|
|
|
// The public string representation of false.
|
|
|
|
public const String FalseString = "False";
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public override void ToString(String strBuffer)
|
|
|
|
{
|
2020-05-26 20:56:19 +01:00
|
|
|
strBuffer.Append(((bool)this) ? TrueString : FalseString);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2020-02-18 08:41:14 -08:00
|
|
|
public int GetHashCode()
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
return ((bool)this) ? 1 : 0;
|
|
|
|
}
|
2020-05-26 20:56:19 +01:00
|
|
|
|
|
|
|
public static Result<bool> Parse(StringView val)
|
|
|
|
{
|
|
|
|
if (val.IsEmpty)
|
|
|
|
return .Err;
|
|
|
|
|
|
|
|
if (val.Equals(TrueString, true))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (val.Equals(FalseString, true))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return .Err;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|