示例#1
0
        private CompareResult CompareDifferentTypes(PrimitiveOperand lhs, PrimitiveOperand rhs)
        {
            object lhsValue = lhs.Value;
            object rhsValue = rhs.Value;

            // Excel has weird rules when comparing values of different types.  Basically it assigns each type a rank and
            // compares the rank of both values.
            int lhsRank = GetTypeRank(lhsValue.GetType());
            int rhsRank = GetTypeRank(rhsValue.GetType());

            return(Compare2CompareResult(lhsRank.CompareTo(rhsRank)));
        }
示例#2
0
 private int IndexOfCommonType(PrimitiveOperand lhs, PrimitiveOperand rhs, OperandType[] types)
 {
     for (int i = 0; i <= types.Length - 1; i++)
     {
         OperandType ot = types[i];
         if (lhs.CanConvertForCompare(ot) & rhs.CanConvertForCompare(ot))
         {
             return(i);
         }
     }
     return(-1);
 }