Exemplo n.º 1
0
        private string GetStringValue(DCExpressionItem item, IDCExpressionContext context)
        {
            if (item == null)
            {
                return(null);
            }
            object v = item.Eval(context);

            return(DCExpression.ToString(v));
        }
Exemplo n.º 2
0
        private double GetDoubleValue(DCExpressionItem item, IDCExpressionContext context, double defaultValue = 0)
        {
            if (item == null)
            {
                return(defaultValue);
            }
            object v = item.Eval(context);

            return(DCExpression.ToDouble(v, defaultValue));
        }
Exemplo n.º 3
0
        private bool GetBooleanValue(DCExpressionItem item, IDCExpressionContext context, bool defaultValue = false)
        {
            if (item == null)
            {
                return(defaultValue);
            }
            object v = item.Eval(context);

            return(DCExpression.ToBoolean(v));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 复制对象
        /// </summary>
        /// <returns>复制品</returns>
        public DCExpression Clone()
        {
            DCExpression result = (DCExpression)this.MemberwiseClone();

            if (this._RootItem != null)
            {
                result._RootItem = this._RootItem.Clone();
            }
            return(result);
        }
Exemplo n.º 5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            DCTokenList   tokens = new DCTokenList(cboExpression.Text);
            StringBuilder result = new StringBuilder();

            for (int iCount = 0; iCount < tokens.Count; iCount++)
            {
                result.AppendLine(iCount.ToString("00") + ":" + tokens[iCount].ToString());
            }
            DCExpression exp = new DCExpression(cboExpression.Text);

            result.AppendLine(exp.ToDebugString());
            MyContext c       = new MyContext();
            object    vresult = exp.Eval(c);

            result.AppendLine("运算结果:" + vresult);
            txtResult.Text = result.ToString();
        }