public JScriptAssertion(string expression, string[] assemblyNames, string[] imports) { if (string.IsNullOrEmpty(expression) || expression.TrimStart().Length == 0) { return; } ProcessDirectives(expression, ref assemblyNames, ref imports); var engine = VsaEngine.CreateEngineAndGetGlobalScope(/* fast */ false, assemblyNames ?? new string[0]).engine; if (imports != null && imports.Length > 0) { foreach (var import in imports) { Import.JScriptImport(import, engine); } } // // We pick on of two expression evaluation strategies depending // on the level of trust available. The full trust version is // faster as it compiles the expression once into a JScript // function and then simply invokes at the time it needs to // evaluate the context. The partial trust strategy is slower // as it compiles the expression each time an evaluation occurs // using the JScript eval. // _evaluationStrategy = FullTrustEvaluationStrategy.IsApplicable() ? (EvaluationStrategy) new FullTrustEvaluationStrategy(expression, engine) : new PartialTrustEvaluationStrategy(expression, engine); }
private object EvalJScript0(string src) { Evaluator.EvaluationStrategy ft = null; if (false) { try { ft = new PartialTrustEvaluationStrategy(src, this, Evaluator.Evaluator.Engine); object hndlr31 = ft.Eval(this); if (hndlr31 != null) { return(hndlr31); } } catch (Exception ex) { writeToLogWarn("ERROR PartialTrustEvaluationStrategy: " + ex); } } try { ft = new FullTrustEvaluationStrategy(src, this, Evaluator.Evaluator.Engine); try { object hndlr31 = ft.Eval(this); if (hndlr31 != null) { return(hndlr31); } } catch (Exception ex) { writeToLogWarn("ERROR FullTrustEvaluationStrategy: " + ex); } } catch (Exception ex) { writeToLogWarn("ERROR FullTrustEvaluationStrategy: " + ex); } try { object hndlr31 = Evaluator.Evaluator.EvalJScript(src); if (hndlr31 != null) { return(hndlr31); } } catch (Exception ex) { writeToLogWarn("ERROR EvalJScript " + ex); return("ERROR EvalJScript: " + ex.Message); } return(null); }