示例#1
0
            public FullTrustEvaluationStrategy(string expression, VsaEngine engine)
                : base(engine)
            {
                //
                // Equivalent to following in JScript:
                // new Function('$context', 'with ($context) return (' + expression + ')');
                //
                // IMPORTANT! Leave the closing parentheses surrounding the
                // return expression on a separate line. This is to guard
                // against someone using a double-slash (//) to comment out
                // the remainder of an expression.
                //

                const string context = "$context";

                _function = LateBinding.CallValue(
                    DefaultThisObject(engine),
                    engine.LenientGlobalObject.Function,
                    new object[] {
                    /* parameters */ context + ",$", /* body... */ @"
                        with (" + context + @") {
                            return (
                                " + expression + @"
                            );
                        }"
                },
                    /* construct */ true, /* brackets */ false, engine);
            }
示例#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));
            }