Ejemplo n.º 1
0
            protected override object DoEvaluate(ScriptingContext context)
            {
                F.Expression resolved = Expression.Resolve(context);
                if (resolved == null)
                {
                    throw new ScriptingException(
                              "Cannot resolve expression `{0}'", Name);
                }

                return(resolved.Evaluate(context));
            }
Ejemplo n.º 2
0
        public string EvaluateExpression(ScriptingContext context, string text,
                                         DisplayFormat format)
        {
            F.Expression expression = context.ParseExpression(text);

            try {
                expression = expression.Resolve(context);
            } catch (ScriptingException ex) {
                throw new ScriptingException("Cannot resolve expression `{0}': {1}",
                                             text, ex.Message);
            } catch {
                throw new ScriptingException("Cannot resolve expression `{0}'.", text);
            }

            try {
                object retval = expression.Evaluate(context);
                return(context.FormatObject(retval, format));
            } catch (ScriptingException ex) {
                throw new ScriptingException("Cannot evaluate expression `{0}': {1}",
                                             text, ex.Message);
            } catch {
                throw new ScriptingException("Cannot evaluate expression `{0}'.", text);
            }
        }