Ejemplo n.º 1
0
        protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
        {
            var cacheKind = OriginalCacheKind.Code;

            byte[] cachedBytes;

            try
            {
                using (OriginalScript generalScript = _jsEngine.Compile(documentName, code, cacheKind,
                                                                        out cachedBytes))
                { }
            }
            catch (OriginalException e)
            {
                throw WrapScriptEngineException(e);
            }

            return(new V8PrecompiledScript(code, cacheKind, cachedBytes, documentName));
        }
Ejemplo n.º 2
0
        public bool ClearScriptCompiled(Parameter parameter)
        {
            using (Microsoft.ClearScript.V8.V8ScriptEngine engine = new Microsoft.ClearScript.V8.V8ScriptEngine())
            {
                Microsoft.ClearScript.V8.V8Script script = engine.Compile(EXPRESSION);

                List <int> results = new List <int>(parameter.Numbers.Length);
                foreach (int number in parameter.Numbers)
                {
                    engine.Script["n"] = number;

                    int result = Convert.ToInt32(engine.Evaluate(script));

                    results.Add(result);
                }

                return(Assert(results, parameter.Sum));
            }
        }