private static T GetVal <T>(this TriboolType type, T indefinitely, T trueVal, T falseVal) { switch (type) { case TriboolType.Indefinitely: return(indefinitely); case TriboolType.True: return(trueVal); case TriboolType.False: return(falseVal); default: return(indefinitely); } }
public Tribool(Tribool tribool) { type = tribool.type; }
public Tribool(bool val) { type = FromBool(val); }
public bool Equals(TriboolType other) { return(Equals(new Tribool(other))); }
public int CompareTo(TriboolType other) { return(CompareTo(new Tribool(other))); }
public static TriboolType Not(this TriboolType type) { return(type.GetVal(TriboolType.Indefinitely, TriboolType.False, TriboolType.True)); }
public static bool IsFalse(this TriboolType tribool) { return(tribool == TriboolType.False); }
public static TriboolType Down(this TriboolType tribool) { return(tribool.IsTrue() ? TriboolType.Indefinitely : TriboolType.False); }
public static int HashCode(this TriboolType type) { return(type.GetVal(1, 2, 3)); }
public static bool IsTrue(this TriboolType tribool) { return(tribool == TriboolType.True); }
public static bool?ToNullableBool(this TriboolType type) { return(type.GetVal <bool?>(null, true, false)); }
public static string ToStrNumber(this TriboolType type) { return(type.GetVal("0", "+1", "-1")); }
public static string ToStr(this TriboolType type) { return(type.GetVal("Indefinitely", "True", "False")); }
public Tribool(TriboolType type) { this.type = type; }
public static bool IsIndefinitely(this TriboolType tribool) { return(tribool == TriboolType.Indefinitely); }
public Tribool(bool?val) { type = FromNullableBool(val); }
public static TriboolType Up(this TriboolType type) { return(type.IsFalse() ? TriboolType.Indefinitely : TriboolType.True); }