using Microsoft.JScript;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks; namespace Soubisc.Infrastructure
{
public static class JEvaluator
{
private const string JScriptSource =
@"
class Evaluator
{
public function Eval(expression : String) : Object
{
return eval(expression);
}
}
";
private static object _evaluator;
private static Type _evaluatorType; static JEvaluator()
{
//构造JScript的编译驱动代码
CodeDomProvider provider = CodeDomProvider.CreateProvider("JScript"); CompilerParameters parameters = new CompilerParameters();
parameters.GenerateInMemory = true; CompilerResults results = provider.CompileAssemblyFromSource(parameters, JScriptSource); Assembly assembly = results.CompiledAssembly;
_evaluatorType = assembly.GetType("Evaluator"); _evaluator = Activator.CreateInstance(_evaluatorType);
} public static object Eval(string statement)
{
return _evaluatorType.InvokeMember(
"Eval",
BindingFlags.InvokeMethod,
null,
_evaluator,
new object[] { statement }
);
}
}
}

JEvaluator Jscript.net的更多相关文章

  1. Microsoft JScript 运行时错误: '$' 未定义

    在运行MVC Music Store时Visual Studio 捕捉到此错误: Microsoft JScript 运行时错误: '$' 未定义 可能是引用的Scripts 引用出错,检查当前文件中 ...

  2. DWZ错误的解决:0x800a13af - Microsoft JScript 运行时错误: 重新声明常量“document”

    在写完Login后,需要跳转到Index中,就是DWZ的主界面,结果出现如下问题: 0x800a13af - Microsoft JScript 运行时错误: 重新声明常量“document” 费了很 ...

  3. JScript中的条件注释详解(转载自网络)

    JScript中的条件注释详解-转载 这篇文章主要介绍了JScript中的条件注释详解,本文讲解了@cc_on.@if.@set.@_win32.@_win16.@_mac等条件注释语句及可用于条件编 ...

  4. 在线API,桌面版,jquery,css,Android中文开发文档,JScript,SQL掌用实例

    学习帮助文档大全 jquery,css,Android中文开发文档,JScript,SQL掌用实例 http://api.jq-school.com/

  5. Microsoft JScript 运行时错误: Sys.WebForms.PageRequestManagerParserErrorException无法分析从服务器收到的消息。之所以出现此错误,

    Microsoft JScript 运行时错误: Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息.之所以出现此错误 ...

  6. Microsoft JScript 运行时错误: Automation 服务器不能创建对象

           var WshShell = new ActiveXObject('WScript.Shell')         WshShell.SendKeys( '{F11}');   问题: ...

  7. 无法找到脚本引擎Jscript解决

    无法找到脚本引擎Jscript解决 CScript 错误: 无法找到脚本“InstallWizardForVS2010.js”的脚本引擎“JScript”. 目标环境:windows 7 64bit系 ...

  8. JScript中的prototype(原型)属性研究

    今天看到同事使用js中的Prototype,感觉很是新鲜.由此想深入学习一下prototype(英['prəʊtətaɪp] 美['protə'taɪp]n. 原型:标准,模范),在学习prototy ...

  9. JavaScript发展史,与JScript差别,引入方式,数据类型,命名规范,命名推荐,解决命名冲突

    文件夹: 1.JavaScript发展史 2.JavaScript与JScript差别 3.JavaScript引入方式 4.JavaScript基本数据类型及布尔值 5.JavaScript命名规范 ...

随机推荐

  1. Hbase之批量删除数据

    import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; impo ...

  2. Android屏幕适配原理

    几个概念: 1) 屏幕密度(dpi) :dot per inch,即每英寸像素数. ldpi(120),mdpi(160),hdpi(240),xhdpi(320) 计算方法: 以480x854,4. ...

  3. struts2 token 使用说明

    使用token标签的时候,Struts2会建立一个GUID(全局唯一的字符串)放在session中,并且会成为一个hidden放在form中. token拦截器会判断客户端form提交的token和s ...

  4. seleniumAccessors

    assertErrorOnNext(message) 告诉Selenium在下一个命令执行时期待有错误. 参数:·message–我们所期望的错误信息.如果出现不正确的错误信息,该命令将失败.同断言相 ...

  5. WindowsService(Windows服务)开发步骤附Demo 【转】

    转http://www.cnblogs.com/moretry/p/4149489.html 1.打开VS,新建项目,选择Windows服务,然后设置目录及项目名称后点击确定. 2.展开Service ...

  6. Qt之加载QSS文件

    简述 Qt中关于样式的使用很常见,为了降低耦合性(与逻辑代码分离),我们通常会定义一个QSS文件,然后编写各种部件(例如:QLable.QLineEdit.QPushButton)的样式,最后使用QA ...

  7. attachEvent ,addEventListener

    if (window.attachEvent) {                  window.attachEvent("onload", remove);           ...

  8. SecureCRT快捷键

    ctrl + a :  移动光标到行首ctrl + e :移动光标到行尾crtl + b:  光标前移1个字符crtl + f :  光标后移1个字符 crtl + h :  删除光标之前的一个字符c ...

  9. BZOJ1520 [POI2006]Szk-Schools

    裸的费用流啊... 建图:对于一个点p拆成两个p1和p2,S向p1连边,流量为1,费用为0:p2向T连边流量为1,费用为0 然后i1向a2到b2分别连边,不妨设i1向p2连边,流量为1,费用为|i - ...

  10. tomcat 集群配置,Session复制共享

    本配置在tomcat7上验证通过.通过此方法配置的集群,session信息将会被自动复制到各个节点. 1.配置Server.xml 在Server.xml中,找到被注释<Cluster/> ...