コード例 #1
0
        /// Evaluate the operation against stack
        public void Eval(IEvaluationContext context, Stack <object> stack)
        {
            string name = null;

            foreach (var option in _options)
            {
                object z;
                if (option.Name != null)
                {
                    name = option.Name;
                    if (context.TryGetValue(option.Name, out z))
                    {
                        stack.Push(z);
                        return;
                    }
                }
                else if (option.Expression != null)
                {
                    option.Expression.Eval(context, stack);
                    return;
                }
                else
                {
                    stack.Push(option.Value);
                    return;
                }
            }
            throw new KeyNotFoundException("Variable '" + name + "' is undefined");
        }
コード例 #2
0
 /// Evaluate the operation against stack
 public void Eval(IEvaluationContext context, Stack<object> stack)
 {
     string name = null;
     foreach (var option in _options)
     {
         object z;
         if (option.Name != null)
         {
             name = option.Name;
             if (context.TryGetValue(option.Name, out z))
             {
                 stack.Push(z);
                 return;
             }
         }
         else if (option.Expression != null)
         {
             option.Expression.Eval(context, stack);
             return;
         }
         else
         {
             stack.Push(option.Value);
             return;
         }
     }
     throw new KeyNotFoundException("Variable '"+name+"' is undefined");
 }