当前位置: 首页>>代码示例>>C#>>正文


C# TokenId.ToString方法代码示例

本文整理汇总了C#中TokenId.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TokenId.ToString方法的具体用法?C# TokenId.ToString怎么用?C# TokenId.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TokenId的用法示例。


在下文中一共展示了TokenId.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EvalStringOperator

 private object EvalStringOperator(TokenId op, object lValue, object rValue)
 {
     switch (op)
     {
         case TokenId.Plus:
             {
                 if (lValue == null)
                 {
                     return rValue;
                 }
                 else
                 {
                     return (lValue.ToString() + rValue);
                 }
             }
         case TokenId.EqualEqual:
             {
                 if (lValue == null)
                 {
                     if (rValue == null)
                         return true;
                     else
                         return false;
                 }
                 else
                 {
                     return lValue.ToString().Equals(rValue);
                 }
             }
         case TokenId.NotEqual:
             {
                 if (lValue == null)
                 {
                     if (rValue == null)
                         return false;
                     else
                         return true;
                 }
                 else
                 {
                     return !lValue.ToString().Equals(rValue);
                 }
             }
         default:
             throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
     }
 }
开发者ID:yslib,项目名称:minimvc,代码行数:47,代码来源:BinaryExpression.cs

示例2: Evaluate

        private object Evaluate(TokenId op, object lValue, object rValue)
        {
            object result = null;

            if (Util.IsInteger(lValue) && Util.IsInteger(rValue))
            {
                result = EvalIntOperator(op, lValue, rValue);
            }
            else if (Util.IsNumber(lValue) && Util.IsNumber(rValue))
            {
                result = EvalDoubleOperator(op, lValue, rValue);
            }
            else if (lValue is DateTime && rValue is DateTime)
            {
                result = EvalDateTimeOperator(op, (DateTime)lValue, (DateTime)rValue);
            }
            else if (lValue is bool && rValue is bool)
            {
                result = EvalBooleanOperator(op, lValue, rValue);
            }
            else if (Util.IsString(lValue) || Util.IsString(rValue))
            {
                result = EvalStringOperator(op, lValue, rValue);
            }
            else
            {
                throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
            }

            return result;
        }
开发者ID:yslib,项目名称:minimvc,代码行数:31,代码来源:BinaryExpression.cs

示例3: EvalIntOperator

        private object EvalIntOperator(TokenId op, object lValue, object rValue)
        {
            long result;

            switch (op)
            {
                case TokenId.Plus:
                case TokenId.PlusEqual:
                    {
                        result = (Convert.ToInt64(lValue) + Convert.ToInt64(rValue));
                        break;
                    }
                case TokenId.Minus:
                case TokenId.MinusEqual:
                    {
                        result = (Convert.ToInt64(lValue) - Convert.ToInt64(rValue));
                        break;
                    }
                case TokenId.Star:
                case TokenId.StarEqual:
                    {
                        result = (Convert.ToInt64(lValue) * Convert.ToInt64(rValue));
                        break;
                    }
                case TokenId.Slash:
                case TokenId.SlashEqual:
                    {
                        return (Convert.ToDouble(lValue) / Convert.ToDouble(rValue));
                    }
                case TokenId.Percent:
                case TokenId.PercentEqual:
                    {
                        result = ((Convert.ToInt64(lValue) % Convert.ToInt64(rValue)));
                        break;
                    }
                case TokenId.EqualEqual:
                    {
                        return Convert.ToInt64(lValue) == Convert.ToInt64(rValue);
                    }
                case TokenId.Less:
                    {
                        return Convert.ToInt64(lValue) < Convert.ToInt64(rValue);
                    }
                case TokenId.LessEqual:
                    {
                        return Convert.ToInt64(lValue) <= Convert.ToInt64(rValue);
                    }
                case TokenId.Greater:
                    {
                        return Convert.ToInt64(lValue) > Convert.ToInt64(rValue);
                    }
                case TokenId.GreaterEqual:
                    {
                        return Convert.ToInt64(lValue) >= Convert.ToInt64(rValue);
                    }
                case TokenId.NotEqual:
                    {
                        return Convert.ToInt64(lValue) != Convert.ToInt64(rValue);
                    }
                default:
                    {
                        throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
                    }
            }

            if (result >= Int32.MinValue && result <= Int32.MaxValue)
                return (int)result;
            else
                return result;
        }
开发者ID:yslib,项目名称:minimvc,代码行数:70,代码来源:BinaryExpression.cs

示例4: EvalDoubleOperator

        private object EvalDoubleOperator(TokenId op, object lValue, object rValue)
        {
            if (lValue is decimal && rValue is decimal)
                return EvalDecimalOperator(op, (decimal)lValue, (decimal)rValue);

            double v1 = Util.ToDouble(lValue);
            double v2 = Util.ToDouble(rValue);

            switch (op)
            {
                case TokenId.Plus:
                case TokenId.PlusEqual:
                    return (v1 + v2);
                case TokenId.Minus:
                case TokenId.MinusEqual:
                    return (v1 - v2);
                case TokenId.Star:
                case TokenId.StarEqual:
                    return (v1 * v2);
                case TokenId.Slash:
                case TokenId.SlashEqual:
                    return (v1 / v2);
                case TokenId.Percent:
                case TokenId.PercentEqual:
                    return (v1 % v2);
                case TokenId.EqualEqual:
                    return (v1 == v2);
                case TokenId.Greater:
                    return (v1 > v2);
                case TokenId.GreaterEqual:
                    return (v1 >= v2);
                case TokenId.Less:
                    return (v1 < v2);
                case TokenId.LessEqual:
                    return (v1 <= v2);
                case TokenId.NotEqual:
                    return (v1 != v2);
                default:
                    throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
            }
        }
开发者ID:yslib,项目名称:minimvc,代码行数:41,代码来源:BinaryExpression.cs

示例5: EvalDecimalOperator

 private object EvalDecimalOperator(TokenId op, decimal v1, decimal v2)
 {
     switch (op)
     {
         case TokenId.Plus:
         case TokenId.PlusEqual:
             return (v1 + v2);
         case TokenId.Minus:
         case TokenId.MinusEqual:
             return (v1 - v2);
         case TokenId.Star:
         case TokenId.StarEqual:
             return (v1 * v2);
         case TokenId.Slash:
         case TokenId.SlashEqual:
             return (v1 / v2);
         case TokenId.Percent:
         case TokenId.PercentEqual:
             return (v1 % v2);
         case TokenId.EqualEqual:
             return (v1 == v2);
         case TokenId.Greater:
             return (v1 > v2);
         case TokenId.GreaterEqual:
             return (v1 >= v2);
         case TokenId.Less:
             return (v1 < v2);
         case TokenId.LessEqual:
             return (v1 <= v2);
         case TokenId.NotEqual:
             return (v1 != v2);
         default:
             throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), v1.GetType().Name, v2.GetType().Name);
     }
 }
开发者ID:yslib,项目名称:minimvc,代码行数:35,代码来源:BinaryExpression.cs

示例6: EvalDateTimeOperator

 private bool EvalDateTimeOperator(TokenId op, DateTime lValue, DateTime rValue)
 {
     switch (op)
     {
         case TokenId.EqualEqual:
             {
                 return lValue == rValue;
             }
         case TokenId.Less:
             {
                 return lValue < rValue;
             }
         case TokenId.LessEqual:
             {
                 return lValue <= rValue;
             }
         case TokenId.Greater:
             {
                 return lValue > rValue;
             }
         case TokenId.GreaterEqual:
             {
                 return lValue >= rValue;
             }
         case TokenId.NotEqual:
             {
                 return lValue != rValue;
             }
         default:
             {
                 throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
             }
     }
 }
开发者ID:yslib,项目名称:minimvc,代码行数:34,代码来源:BinaryExpression.cs

示例7: EvalBooleanOperator

        private object EvalBooleanOperator(TokenId op, object lValue, object rValue)
        {
            bool v1 = Util.ToBool(lValue);
            bool v2 = Util.ToBool(rValue);

            switch (op)
            {
                case TokenId.Or: return v1 | v2;
                case TokenId.And: return v1 & v2;
                case TokenId.EqualEqual: return (v1 == v2);
                case TokenId.NotEqual: return (v1 != v2);
                default: throw new ParseException("BinaryNotSupport '{0}' between type of '{1}' and '{2}'", op.ToString(), lValue.GetType().Name, rValue.GetType().Name);
            }
        }
开发者ID:yslib,项目名称:minimvc,代码行数:14,代码来源:BinaryExpression.cs


注:本文中的TokenId.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。