public static Primary operator %(Primary a, Primary b) { Primary r = new Primary(); r.DataType = ResultantDataType(a, b); switch (r.DataType) { case PrimaryType.INT: return new Primary(a.GetInt() % b.GetInt()); case PrimaryType.LONG: return new Primary(a.GetLong() % b.GetLong()); case PrimaryType.BOOL: throw new Exception("The % operator can not be used on boolean values."); case PrimaryType.DOUBLE: throw new Exception("The % operator can not be used on double values."); case PrimaryType.STRING: throw new Exception("The % operator can not be used on string values."); case PrimaryType.REGEX: throw new Exception("The % operator can not be used on RegEx values."); case PrimaryType.DATETIME: throw new Exception("The % operator can not be used on DateTime values."); case PrimaryType.TIMESPAN: throw new Exception("The % operator can not be used on TimeSpan values."); default: throw new Exception("Invalid use of the + operator."); } }
private static Primary Plus(Primary x, Primary y) { return null; }
private static PrimaryType ResultantDataType(Primary a, Primary b) { if (a.DataType == PrimaryType.STRING || b.DataType == PrimaryType.STRING) return PrimaryType.STRING; if (a.DataType == PrimaryType.DOUBLE || b.DataType == PrimaryType.DOUBLE) return PrimaryType.DOUBLE; if (a.DataType == PrimaryType.LONG || b.DataType == PrimaryType.LONG) return PrimaryType.LONG; return a.DataType; }
internal void SetValue(bool value) { _value = new Primary(value); }
internal void Reset() { _value = null; this.TokenType = TokenType.INVALID; this.IsOK = true; }
internal void SetValue(TimeSpan value) { _value = new Primary(value); }
internal void SetValue(DateTime value) { _value = new Primary(value); }
internal void SetValue(Regex value) { _value = new Primary(value); }
internal void SetValue(string value) { _value = new Primary(value); }
internal void SetValue(double value) { _value = new Primary(value); }