Beispiel #1
0
        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.");
            }
        }
Beispiel #2
0
 private static Primary Plus(Primary x, Primary y)
 {
     return null;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 internal void SetValue(bool value)
 {
     _value = new Primary(value);
 }
Beispiel #5
0
 internal void Reset()
 {
     _value = null;
     this.TokenType = TokenType.INVALID;
     this.IsOK = true;
 }
Beispiel #6
0
 internal void SetValue(TimeSpan value)
 {
     _value = new Primary(value);
 }
Beispiel #7
0
 internal void SetValue(DateTime value)
 {
     _value = new Primary(value);
 }
Beispiel #8
0
 internal void SetValue(Regex value)
 {
     _value = new Primary(value);
 }
Beispiel #9
0
 internal void SetValue(string value)
 {
     _value = new Primary(value);
 }
Beispiel #10
0
 internal void SetValue(double value)
 {
     _value = new Primary(value);
 }