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. django在pyhton2.7 和 python3.* 之间代码和睦相处的方法

    “祥”龙第一掌: from __future__ import unicode_literals from django.utils.encoding import python_2_unicode_ ...

  2. ManyToMany关联方式----

    http://blog.csdn.net/sinat_18882775/article/details/51171427 好的博客 系列文章总结

  3. js中Math.random()生成指定范围数值的随机数

    http://www.111cn.net/wy/js-ajax/57062.htm Math.random() 这个方法相信大家都知道,是用来生成随机数的.不过一般的参考手册时却没有说明如何用这个方法 ...

  4. graph-tool文档(一)- 快速开始使用Graph-tool - 3.图的过滤

    目录: 图的过滤 图视图 -- 组合图视图 名词解释: filter:过滤 mask:屏蔽 inverted parameter:倒参数 overhead:开销 minimum spanning tr ...

  5. 基于SourceTree 下的 Git Flow 模型

    基于SourceTree 下的 Git Flow 模型 1. sourceTree  是一个开源的git 图形管理工具,可下载mac版本,windows版本 2. Git Flow 是一套使用Git进 ...

  6. flasCC技术点记录

    [待测试特性] 一.C接口导出相关 1.重载函数. 2.虚函数. 3.template相关 二.内存相关 1.as直接往c分配的内存写数据. 2.c直接往as对象写数据. 三.C访问AS 1.访问as ...

  7. centos svn服务器安装

    1.安装必须的软件 yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql 2.创建代码库 mkdir -p /root ...

  8. JavaScript 3D图表

    在说3D图表以前,首先要明确两个概念,一个是数据的维度,一个是呈现数据载体的维度.对于数据的维度,一维的数据呈现,但是呈现的载体是二维的平面图,比如饼图: 已经能够很清晰地观察到数据的分布情况.数据如 ...

  9. Qt之可重入与线程安全

    简述 本篇文章中,术语"可重入性"和"线程安全"被用来标记类与函数,以表明它们如何被应用在多线程应用程序中. 一个线程安全的函数可以同时被多个线程调用,甚至调用 ...

  10. hiphop-php 搭建 (CentOS)

    前提:只支持64位系统 升级GCC: https://github.com/jackywei/HOW-TO-BUILD-HHVM-WiKi/wiki/Build-&-Install-GCC4. ...