Ejemplo n.º 1
0
 private static FactorDataType ResultantDataType(Factor a, Factor b)
 {
     if (a.DataType == FactorDataType.STRING || b.DataType == FactorDataType.STRING) return FactorDataType.STRING;
     if (a.DataType == FactorDataType.DOUBLE || b.DataType == FactorDataType.DOUBLE) return FactorDataType.DOUBLE;
     if (a.DataType == FactorDataType.LONG || b.DataType == FactorDataType.LONG) return FactorDataType.LONG;
     return a.DataType;
 }
Ejemplo n.º 2
0
        public static Factor operator %(Factor a, Factor b)
        {
            Factor r = new Factor();

            r.DataType = ResultantDataType(a, b);

            switch (r.DataType) {
                case FactorDataType.INT:
                    return new Factor(a.GetInt() % b.GetInt());
                case FactorDataType.LONG:
                    return new Factor(a.GetLong() % b.GetLong());
                case FactorDataType.BOOL:
                    throw new Exception("The % operatore can not be used on boolean values.");
                case FactorDataType.DOUBLE:
                    throw new Exception("The % operatore can not be used on double values.");
                case FactorDataType.STRING:
                    throw new Exception("The % operatore can not be used on string values.");
                case FactorDataType.REGEX:
                    throw new Exception("The % operatore can not be used on RegEx values.");
                case FactorDataType.DATETIME:
                    throw new Exception("The % operatore can not be used on DateTime values.");
                case FactorDataType.TIMESPAN:
                    throw new Exception("The % operatore can not be used on TimeSpan values.");
                default:
                    throw new Exception("Invalid use of the + operator.");
            }
        }
Ejemplo n.º 3
0
 private static Factor Plus(Factor x, Factor y)
 {
     return null;
 }