Example #1
0
 // Send code block to Phalanger to be executed
 // TODO: include line numbers, file names, and other useful stuff
 private object PhpEval(ScriptContext context, string code)
 {
     return(DynamicCode.Eval(
                code,
                false,
                context,
                null,
                null,
                null,
                "default",
                1, 1,
                -1,
                null
                ));
 }
Example #2
0
        public bool Validate(string text)
        {
            var scope     = _context.Fork();
            var localVars = new Dictionary <string, object> {
                { "text", text }
            };

            return(System.Convert.ToBoolean(
                       DynamicCode.Eval(
                           CustomRuleCode,
                           false,
                           scope,
                           localVars,
                           null,
                           null,
                           "dummy.cs",
                           1,
                           1,
                           -1,
                           null)));
        }
 public dynamic ExecuteExpression(string expression, ScriptScope scope)
 {
     return
         (RunPhpExecutor(
              requestContext =>
     {
         DynamicCode.Eval(
             expression,
             false,              // Phalanger internal stuff
             requestContext.ScriptContext,
             null,               // local variables
             null,               // reference to "$this"
             null,               // current class context
             scope.Name,         // file name, used for debug and cache key
             1, 1,               // position in the file used for debug and cache key
             -1,                 // something internal
             null                // current namespace, used in CLR mode
             );
     },
              scope));
 }