Esempio n. 1
0
        /// <summary>
        /// Acceptor of binary operation
        /// </summary>
        /// <param name="typeA">Type of left part</param>
        /// <param name="typeB">Type of right part</param>
        /// <returns>Accepted operation</returns>
        public IObjectOperation Accept(object typeA, object typeB)
        {
            IObjectOperation op = DateTimeMoreComparator.Object.Accept(typeA, typeB);

            if (op != null)
            {
                if (symbol == '>')
                {
                    return(DateTimeMoreComparator.Object);
                }
                if (symbol == '<')
                {
                    return(DateTimeLessCompatrator.Object);
                }
            }
            if (!ElementaryBinaryOperation.IsNumber(typeA) | !ElementaryBinaryOperation.IsNumber(typeB))
            {
                return(null);
            }
            return(this);
        }
Esempio n. 2
0
 /// <summary>
 /// Accepts operation
 /// </summary>
 /// <param name="type">Argument type</param>
 /// <returns>The operation</returns>
 public IObjectOperation Accept(object type)
 {
     if (!ElementaryBinaryOperation.IsNumber(type))
     {
         if (!addAcceptors.ContainsKey(type))
         {
             return(null);
         }
         List <IOperationAcceptor> l = addAcceptors[type];
         foreach (IOperationAcceptor acc in l)
         {
             IObjectOperation op = acc.Accept(type);
             if (op != null)
             {
                 return(op);
             }
         }
         return(null);
     }
     return(new ElementaryIntegerOperation(symbol, type));
 }
Esempio n. 3
0
 /// <summary>
 /// Acceptor of binary operation
 /// </summary>
 /// <param name="typeA">Type of left part</param>
 /// <param name="typeB">Type of right part</param>
 /// <returns>Accepted operation</returns>
 public IObjectOperation Accept(object typeA, object typeB)
 {
     if (!ElementaryBinaryOperation.IsInteger(typeA))
     {
         throw new Exception("Illegal integer argument");
     }
     if ((symbol == '\u2266') | (symbol == '\u2267'))
     {
         if (!ElementaryBinaryOperation.IsNumber(typeB))
         {
             throw new Exception("Illegal integer argument");
         }
         type = typeA;
         return(this);
     }
     if (!typeA.Equals(typeB))
     {
         throw new Exception("Different types of integer");
     }
     type = typeA;
     return(this);
 }