Beispiel #1
0
        public virtual String Evaluate(string expr)
        {
            var engine = (INeedEngine)this;
            var result = Eval.JScriptEvaluate(expr, engine.GetEngine());

            return(Convert.ToString(result, true));
        }
Beispiel #2
0
            public override bool Eval(object context)
            {
                //
                // Following is equivalent to calling apply in JScript.
                // See http://msdn.microsoft.com/en-us/library/84ht5z59.aspx.
                //

                object result = LateBinding.CallValue(
                    DefaultThisObject(Engine),
                    _function, /* args */ new object[] { context, context },
                    /* construct */ false, /* brackets */ false, Engine);

                return(Convert.ToBoolean(result));
            }
            public override bool Eval(object context)
            {
                VsaEngine engine = Engine;

                //
                // Following is equivalent to calling eval in JScript,
                // with the value of the context variable established at the
                // global scope in order for it to be available to the
                // expression source.
                //

                _contextField.SetValue(_scope, context);

                try
                {
                    With.JScriptWith(context, engine);
                    return(Convert.ToBoolean(Microsoft.JScript.Eval.JScriptEvaluate(_expression, engine)));
                }
                finally
                {
                    engine.PopScriptObject(/* with */);
                }
            }