-
大小: 2.29MB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-11-16
- 語言: JavaScript
- 標簽: V8??腳本引擎??C#??.NET??
資源簡介
在.NET中可供集成的腳本語言有很多種選擇,LUA 和 Phython 都有非常成熟的解決方案。而JavaScript作為一種比較流行的腳本語言,也是非常不錯的選擇。
http://blog.csdn.net/wangjia184/article/details/8520725

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Web;
using?System.Web.UI;
using?System.Web.UI.WebControls;
namespace?GooglejavascriptV8EngineSample
{
????public?partial?class?Default?:?System.Web.UI.Page
????{
????????protected?void?Page_Load(object?sender?EventArgs?e)
????????{
????????????//?注冊回調(diào)函數(shù),用于處理由JS中主動發(fā)起的調(diào)用
????????????javascriptEngine.RegisterCommandCallback(CommandCallback);
????????}
????????
????????protected?void?btnSubmit_Click(object?sender?EventArgs?e)
????????{
????????????lbError.Text?=?string.Empty;
????????????txtOutput.Text?=?string.Empty;
????????????try
????????????{
????????????????txtOutput.Text?=?javascriptEngine.Execute(txtInput.Text);
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????lbError.Text?=?ex.Message;
????????????}
????????}
????????///?
????????///?注冊的回調(diào)方法,用于處理JS中的_exeCommand調(diào)用
????????///?
????????///?
????????///?
????????///?
????????///?
????????private?string?CommandCallback(string?command?string?arg1?string?arg2)
????????{
????????????switch?(command.ToLowerInvariant())
????????????{
????????????????case?“average“:
????????????????????{
????????????????????????string?[]?items?=?arg1.Split(new?char[]?{?‘‘?}?StringSplitOptions.RemoveEmptyEntries);
????????????????????????return?items.Average(?i?=>?int.Parse(i)).ToString();
????????????????????}
????????????????default:
????????????????????return?null;
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-01-19?19:35??bin\
?????文件????????7680??2013-01-19?20:01??bin\Googleja
?????文件???????19968??2013-01-19?20:01??bin\Googleja
?????文件?????3589632??2013-01-19?19:13??bin\GoogleV8Engine_x64.dll
?????文件?????2408960??2013-01-19?19:14??bin\GoogleV8Engine_x86.dll
?????文件????????1954??2013-01-19?20:02??Default.aspx
?????文件????????1721??2013-01-19?20:01??Default.aspx.cs
?????文件????????2103??2013-01-19?19:44??Default.aspx.designer.cs
?????文件?????????108??2013-01-19?19:16??Global.asax
?????文件????????1207??2013-01-19?19:16??Global.asax.cs
?????文件????????4587??2013-01-19?19:35??Googleja
?????文件????????3889??2013-01-19?19:42??GoogleV8Engine.cs
?????目錄???????????0??2013-01-19?19:16??Properties\
?????文件????????1419??2013-01-19?19:16??Properties\AssemblyInfo.cs
?????文件?????????573??2013-01-19?19:30??Web.config
?????文件????????1285??2013-01-19?19:16??Web.Debug.config
?????文件????????1346??2013-01-19?19:16??Web.Release.config
評論
共有 條評論