SuperScript是C#脚本引擎,它为您的WinForms和WPF应用程序带来了高效的代码编辑功能。
它提供了代码编辑功能,如语法高亮显示、智能代码提示和代码完成、语法错误,
它支持类库引用,编译及导出等等,使用它好比您在Visual Studio中编码一样,速度和便利性相媲美。
使用它,可以极大的发挥您的应用程序扩展和开放性,
使得您的程序在发布后,也可支持用户自定义编辑和运行脚本。
编辑
以下是扩展简单示例:
比如您的应用程序有个计算功能,它允许用户根据用户输入值,通过编辑脚本自定义输出结果功能,如实现字符串倒叙功能。
编辑
示例代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using Wagwei.FCL.SuperScript;
namespace TestScript { public partial class FrmTest : Form { private CalcBase calcBase = null; private WagScriptBuild build = null; private string _script = "";
public FrmTest()
{
InitializeComponent();
string data = File.ReadAllText(Path.Combine(Application.StartupPath, "demo.wagscript"));
_script = data;
}
private void _Load(object sender, EventArgs e)
{
build = new WagScriptBuild<CalcBase>(_script);
calcBase = build.BuildScript(false);
}
public class CalcBase
{
public virtual string Calc(string input)
{
string output = input;
return output;
}
}
/// <summary>修改脚本</summary>
private void btn_srcipt_Click(object sender, EventArgs e)
{
build.EditExistingScript(true);
string s = build.m_WagScriptSupport.SaveToStr("");
_script = s;
calcBase = build.BuildScript(false);
}
/// <summary>计算</summary>
private void btn_run_Click(object sender, EventArgs e)
{
string input = this.txt_input.Text.Trim();
string output = this.calcBase.Calc(input);
this.txt_output.Text = output;
}
}
}