Exemplo n.º 1
0
 protected override bool IsEvalableType(Type type)
 {
     if (type == null)
     {
         return(true);
     }
     if (BinaryHelper.IsPrimitiveType(type))
     {
         return(true);
     }
     if (type == typeof(string))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        protected override void ProcessArg(Evaluator evaluater, Result[] argArray)
        {
            base.ProcessArg(evaluater, argArray);
            Type type0 = argArray[0].Type;
            Type type1 = argArray[1].Type;

            if (type0 == null && type1 == null)
            {
                return;
            }

            if (type0 == null)
            {
                if (type1.IsValueType)
                {
                    throw new InvalidCastException(string.Format("from null to {0}", type1.Name));
                }
            }
            if (type1 == null)
            {
                if (type0.IsValueType)
                {
                    throw new InvalidCastException(string.Format("from null to {0}", type0.Name));
                }
            }

            int result;

            if (BinaryHelper.ComparePrimitiveType(type0, type1, out result))
            {
                if (result > 0)
                {
                    argArray[1].Value = ConvertHelper.ChangeType(argArray[1].Value, type0);
                }
                else if (result < 0)
                {
                    argArray[0].Value = ConvertHelper.ChangeType(argArray[0].Value, type1);
                }
            }
        }
Exemplo n.º 3
0
 protected override bool IsEvalableType(Type type)
 {
     return(BinaryHelper.IsPrimitiveType(type));
 }