本文整理汇总了C#中ScriptEngine.SetGlobalFunction方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptEngine.SetGlobalFunction方法的具体用法?C# ScriptEngine.SetGlobalFunction怎么用?C# ScriptEngine.SetGlobalFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptEngine
的用法示例。
在下文中一共展示了ScriptEngine.SetGlobalFunction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGlobalFunction
public void SetGlobalFunction()
{
var engine = new ScriptEngine();
// Try a static delegate.
engine.SetGlobalFunction("add", new Func<int, int, int>((a, b) => a + b));
Assert.AreEqual(11, engine.Evaluate("add(5, 6)"));
// Try an instance delegate.
engine.SetGlobalFunction("global", new Func<object>(() => engine.Global));
Assert.AreEqual(5, engine.Evaluate("global().parseInt('5')"));
}
示例2: BindToEngine
public static void BindToEngine(ScriptEngine engine)
{
engine.SetGlobalFunction("RequireScript", new Action<string>(RequireScript));
engine.SetGlobalFunction("RequireSystemScript", new Action<string>(RequireSystemScript));
engine.SetGlobalFunction("EvaluateScript", new Action<string>(EvaluateScript));
engine.SetGlobalFunction("EvaluateSystemScript", new Action<string>(EvaluateSystemScript));
engine.Execute("Object.defineProperty(Object.prototype, \"__defineGetter__\", { value: function(name, func) {" +
"Object.defineProperty(this, name, { get: func, configurable: true }); } });");
engine.Execute("Object.defineProperty(Object.prototype, \"__defineSetter__\", { value: function(name, func) {" +
"Object.defineProperty(this, name, { set: func, configurable: true }); } });");
}
示例3: Construct
/// <summary>
/// Creates and configures a Jurassic ScriptEngine
/// </summary>
/// <param name="context">The request/response context to process</param>
/// <returns>A RaptorJS-configured Jurassic ScriptEngine instance</returns>
public static ScriptEngine Construct(HttpListenerContext context)
{
ScriptEngine engine = new ScriptEngine();
engine.SetGlobalValue("Request", new RequestInstance(engine, context.Request));
engine.SetGlobalValue("Response", new ResponseInstance(engine, context.Response));
engine.SetGlobalValue("console", new ConsoleInstance(engine));
engine.SetGlobalValue("file", new FileSystemInstance(engine));
engine.SetGlobalFunction("require", new Action<string>((path) => engine.ExecuteFile(path)));
engine.SetGlobalFunction("require", new Func<string, object>((path) => engine.Evaluate(new FileScriptSource(path))));
return engine;
}
示例4: RequireJsCompiler
public RequireJsCompiler(TextWriter consoleOut, string currentDirectory)
{
_jsEngine = new ScriptEngine();
_jsEngine.CompatibilityMode = CompatibilityMode.ECMAScript3;
_jsEngine.Evaluate(LoadResource("require.js"));
_jsEngine.Evaluate(LoadResource("json2.js"));
_jsEngine.Evaluate(LoadResource(@"adapt\rhino.js"));
_jsEngine.Evaluate("require(" + new JavaScriptSerializer().Serialize(new {
baseUrl = ResourceBaseUrl
}) + ");");
_fs = new NativeFS(_jsEngine, currentDirectory);
_jsEngine.SetGlobalValue("YUNoFS", _fs);
_path = new NativePath(_jsEngine, currentDirectory);
_jsEngine.SetGlobalValue("YUNoPath", _path);
_ioAdapter = new IOAdapter(_jsEngine, consoleOut);
_jsEngine.SetGlobalFunction("load", (Action<string>)_ioAdapter.load);
_jsEngine.SetGlobalValue("ioe", _ioAdapter);
_jsEngine.SetGlobalValue("IsRunningYUNoAMD", true);
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "env.js", @"build\jslib\env.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "yunoamd/args.js", @"build\jslib\yunoamd\args.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "build.js", @"build\build.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "print.js", @"build\jslib\yunoamd\print.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "fs.js", @"build\jslib\yunoamd\fs.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "path.js", @"build\jslib\yunoamd\path.js");
SetupModuleFromResource(RequireJsCompiler.ResourceBaseUrl + "file.js", @"build\jslib\node\file.js");
}
示例5: LessCompiler
public LessCompiler()
{
engine = new ScriptEngine();
engine.Execute("window = { location: { href: '/', protocol: 'http:', host: 'localhost' } };");
engine.SetGlobalFunction("xhr", new Action<ObjectInstance, ObjectInstance, FunctionInstance, FunctionInstance>(Xhr));
engine.Execute(Properties.Resources.less);
}
示例6: register
public static void register(ScriptEngine engine, IWin32Window parentForm = null)
{
engine.SetGlobalFunction("getFiles", new Func<string, ObjectInstance>((s) => getFiles(s, engine).toArrayInstance(engine)));
engine.SetGlobalFunction("getDirectories", new Func<string, ObjectInstance>((s) => getDirectories(s, engine).toArrayInstance(engine)));
engine.SetGlobalFunction("readFile", new Func<string, string>((s) => readFile(s, engine)));
engine.SetGlobalFunction("writeFile", new Action<string, string>((s, c) => writeFile(s, c, engine)));
engine.SetGlobalFunction("deleteFile", new Action<string>((s) => deleteFile(s, engine)));
engine.SetGlobalFunction("openFileDialog", new Func<string, string, bool, ObjectInstance>((p, t, m) => callOpenFileDialog(p, t, m, parentForm, engine).toArrayInstance(engine)));
engine.SetGlobalFunction("saveFileDialog", new Func<string, string, string>((p, t) => callSaveFileDialog(p, t, parentForm, engine)));
}
示例7: Too_Many_Arguments_To_Clr_Method_Is_Error
public void Too_Many_Arguments_To_Clr_Method_Is_Error()
{
int value = 0;
ScriptEngine engine = new ScriptEngine();
engine.SetGlobalFunction<int>("DoIt", (x) => { value += x; });
Assert.Throws<ScriptExecutionException>(() =>
{
engine.Execute(@"DoIt(12, 12);");
});
}
示例8: Setup
public void Setup()
{
engine = new ScriptEngine { EnableDebugging = true };
engine.SetGlobalValue("nativeModule", new NativeModuleInstance(engine));
engine.SetGlobalValue("console", new FirebugConsole(engine));
engine.SetGlobalFunction("native_require", new Func<string, ObjectInstance>(identifier =>
{
switch (identifier)
{
case "nativeModule":
return new NativeModuleInstance(engine);
default:
throw new ArgumentOutOfRangeException(string.Format("Unsupported module name: {0}", identifier));
}
}));
engine.ExecuteFile("./Builtin/require.js");
}
示例9: JsEngine
public JsEngine(Main main)
{
_scriptEngine = new ScriptEngine();
_scriptEngine.SetGlobalFunction("Pause", new Action<int>(Utils.Pause));
_scriptEngine.SetGlobalValue("Bebop", new Api(main,_scriptEngine));
_scriptEngine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(_scriptEngine));
//_scriptEngine.EnableDebugging = true;
//_scriptEngine.ExecuteFile("Test.js");
string windows = "";
foreach (Windows w in Enum.GetValues(typeof(Windows)))
{
if (windows != "") windows += ",";
windows += Enum.GetName(typeof(Windows), w) + " : " + (int)w;
}
_scriptEngine.Execute("var Windows={ " + windows + " };");
}
示例10: JsHost
public JsHost(ScriptEngine engine, IJinxBotClient client)
{
Debug.Assert(engine != null);
Debug.Assert(client != null);
_engine = engine;
_client = client;
_jsClient = new JsJinxBotClientObjectInstance(client, this, engine);
_engine.SetGlobalValue("Colors", new Colors(engine));
_engine.SetGlobalValue("CssClasses", new CssClasses(engine));
_engine.SetGlobalFunction("send", (Action<string>)send);
_engine.SetGlobalFunction("addChat", (Action<ArrayInstance>)addChat);
_engine.SetGlobalFunction("format", (Func<string, ArrayInstance, string>)format);
_engine.SetGlobalFunction("setTimeout", (Func<double, ObjectInstance, int>)setTimeout);
_engine.SetGlobalFunction("clearTimeout", (Action<int>)clearTimeout);
_engine.SetGlobalFunction("setInterval", (Func<double, ObjectInstance, int>)setInterval);
_engine.SetGlobalFunction("clearInterval", (Action<int>)clearInterval);
FunctionInstance instance = engine.Evaluate(DUMP_FUNC) as FunctionInstance;
engine.SetGlobalValue("dump", instance);
engine.SetGlobalValue("client", _jsClient);
}
示例11: ExecuteScript
private void ExecuteScript(object sender, RoutedEventArgs e)
{
this.textBoxConsole.Clear();
var engine = new ScriptEngine();
engine.SetGlobalFunction("print", new Action<string>(s => this.textBoxConsole.AppendText(s)));
engine.SetGlobalFunction("println", new Action<string>(s => this.textBoxConsole.AppendText(s + Environment.NewLine)));
engine.SetGlobalFunction("getRows", new Func<int>(() => this.nudRows.Value ?? 1));
engine.SetGlobalFunction("getColumns", new Func<int>(() => this.nudColumns.Value ?? 1));
engine.SetGlobalFunction("setRows", new Action<int>(i => this.nudRows.Value = i));
engine.SetGlobalFunction("setColumns", new Action<int>(i => this.nudColumns.Value = i));
engine.SetGlobalFunction("invertAll", new Action(() => this.cellCollection.InvertCommand.Execute(null)));
engine.SetGlobalFunction("clearAll", new Action(() => this.cellCollection.ClearCommand.Execute(null)));
engine.SetGlobalFunction("isFilled", new Func<int, int, bool>((x, y) => (this.cellCollection.CellAt(x, y) ?? new Cell()).IsFilled));
engine.SetGlobalFunction("setFilled", new Action<int, int, bool>((x, y, fill) => (this.cellCollection.CellAt(x, y) ?? new Cell()).IsFilled = fill));
engine.SetGlobalFunction("setBorderColor", new Action<string>(s =>
{
try
{
this.colorPickerBorder.SelectedColor = (Color)ColorConverter.ConvertFromString(s);
}
catch (FormatException ex)
{
throw new JavaScriptException(engine, "Error", "Cannot parse color: " + s, ex);
}
}));
try
{
engine.Execute(this.textBoxCode.Text);
}
catch (JavaScriptException ex)
{
this.textBoxConsole.Text += "-------------------" + Environment.NewLine + "Error: " + ex.Message;
}
}
示例12: BindToEngine
public static void BindToEngine(ScriptEngine engine)
{
engine.SetGlobalFunction("CreatePerson", new Action<string, string, bool>(CreatePerson));
engine.SetGlobalFunction("DestroyPerson", new Action<string>(DestroyPerson));
engine.SetGlobalFunction("SetPersonX", new Action<string, int>(SetPersonX));
engine.SetGlobalFunction("SetPersonY", new Action<string, int>(SetPersonY));
engine.SetGlobalFunction("GetPersonX", new Func<string, int>(GetPersonX));
engine.SetGlobalFunction("GetPersonY", new Func<string, int>(GetPersonY));
engine.SetGlobalFunction("SetPersonXFloat", new Action<string, double>(SetPersonXFloat));
engine.SetGlobalFunction("SetPersonYFloat", new Action<string, double>(SetPersonYFloat));
engine.SetGlobalFunction("GetPersonXFloat", new Func<string, double>(GetPersonXFloat));
engine.SetGlobalFunction("GetPersonYFloat", new Func<string, double>(GetPersonXFloat));
engine.SetGlobalFunction("SetPersonXY", new Action<string, int, int>(SetPersonXY));
engine.SetGlobalFunction("SetPersonXYFloat", new Action<string, double, double>(SetPersonXYFloat));
engine.SetGlobalFunction("SetPersonVisible", new Action<string, bool>(SetPersonVisible));
engine.SetGlobalFunction("IsPersonVisible", new Func<string, bool>(IsPersonVisible));
engine.SetGlobalFunction("QueuePersonCommand", new Action<string, int, bool>(QueuePersonCommand));
engine.SetGlobalFunction("QueuePersonScript", new Action<string, object, bool>(QueuePersonScript));
engine.SetGlobalFunction("IsCommandQueueEmpty", new Func<string, bool>(IsCommandQueueEmpty));
engine.SetGlobalFunction("GetPersonMask", new Func<string, object>(GetPersonMask));
engine.SetGlobalFunction("SetPersonMask", new Action<string, ColorInstance>(SetPersonMask));
engine.SetGlobalFunction("SetPersonSpeedXY", new Action<string, double, double>(SetPersonSpeedXY));
engine.SetGlobalFunction("SetPersonSpeed", new Action<string, double>(SetPersonSpeed));
engine.SetGlobalFunction("GetPersonSpeedX", new Func<string, double>(GetPersonSpeedX));
engine.SetGlobalFunction("GetPersonSpeedY", new Func<string, double>(GetPersonSpeedY));
engine.SetGlobalFunction("SetPersonFrame", new Action<string, int>(SetPersonFrame));
engine.SetGlobalFunction("GetPersonFrame", new Func<string, int>(GetPersonFrame));
engine.SetGlobalFunction("SetPersonDirection", new Action<string, string>(SetPersonDirection));
engine.SetGlobalFunction("GetPersonDirection", new Func<string, string>(GetPersonDirection));
engine.SetGlobalFunction("SetPersonOffsetX", new Action<string, double>(SetPersonOffsetX));
engine.SetGlobalFunction("SetPersonOffsetY", new Action<string, double>(SetPersonOffsetY));
engine.SetGlobalFunction("GetPersonOffsetX", new Func<string, double>(GetPersonOffsetX));
engine.SetGlobalFunction("GetPersonOffsetY", new Func<string, double>(GetPersonOffsetY));
engine.SetGlobalFunction("SetPersonLayer", new Action<string, int>(SetPersonLayer));
engine.SetGlobalFunction("GetPersonLayer", new Func<string, int>(GetPersonLayer));
engine.SetGlobalFunction("GetPersonBase", new Func<string, object>(GetPersonBase));
engine.SetGlobalFunction("GetCurrentPerson", new Func<string>(GetCurrentPerson));
engine.SetGlobalFunction("GetObstructingPerson", new Func<string>(GetObstructingPerson));
engine.SetGlobalFunction("ClearPersonCommands", new Action<string>(ClearPersonCommands));
engine.SetGlobalFunction("GetPersonList", new Func<ArrayInstance>(GetPersonList));
engine.SetGlobalFunction("GetPersonFrameRevert", new Func<string, int>(GetPersonFrameRevert));
engine.SetGlobalFunction("SetPersonFrameRevert", new Action<string, int>(SetPersonFrameRevert));
engine.SetGlobalFunction("GetPersonSpriteset", new Func<string, object>(GetPersonSpriteset));
engine.SetGlobalFunction("SetPersonSpriteset", new Action<string, SpritesetInstance>(SetPersonSpriteset));
engine.SetGlobalFunction("GetPersonData", new Func<string, object>(GetPersonData));
engine.SetGlobalFunction("SetPersonData", new Action<string, ObjectInstance>(SetPersonData));
engine.SetGlobalFunction("SetPersonValue", new Action<string, string, object>(SetPersonValue));
engine.SetGlobalFunction("GetPersonValue", new Func<string, string, object>(GetPersonValue));
engine.SetGlobalFunction("SetPersonScript", new Action<string, int, object>(SetPersonScript));
engine.SetGlobalFunction("CallPersonScript", new Action<string, int>(CallPersonScript));
engine.SetGlobalFunction("DoesPersonExist", new Func<string, bool>(DoesPersonExist));
engine.SetGlobalFunction("IsIgnoringPersonObstructions", new Func<string, bool>(IsIgnoringPersonObstructions));
engine.SetGlobalFunction("IsIgnoringTileObstructions", new Func<string, bool>(IsIgnoringTileObstructions));
engine.SetGlobalFunction("IgnorePersonObstructions", new Action<string, bool>(IgnorePersonObstructions));
engine.SetGlobalFunction("IgnoreTileObstructions", new Action<string, bool>(IgnoreTileObstructions));
engine.SetGlobalFunction("IsPersonObstructed", new Func<string, double, double, bool>(IsPersonObstructed));
engine.SetGlobalFunction("SetTalkDistance", new Action<int>(SetTalkDistance));
engine.SetGlobalFunction("GetTalkDistance", new Func<int>(GetTalkDistance));
}
示例13: BindToEngine
public static void BindToEngine(ScriptEngine engine)
{
engine.SetGlobalFunction("CreateEmitter", new Func<ImageInstance, ColorInstance, double, double, EmitterInstance>(CreateEmitter));
engine.SetGlobalFunction("UpdateParticles", new Action<double>(Update));
engine.SetGlobalFunction("RenderParticles", new Action<double, double>(Render));
}
示例14: GetSphereEngine
public static ScriptEngine GetSphereEngine()
{
ScriptEngine engine = new ScriptEngine();
// The glorious Sphere game API :)
engine.SetGlobalFunction("Abort", new Action<string>(Abort));
engine.SetGlobalFunction("GetVersion", new Func<double>(GetVersion));
engine.SetGlobalFunction("GetVersionString", new Func<string>(GetVersionString));
engine.SetGlobalFunction("GetExtensions", new Func<ArrayInstance>(GetExtensions));
engine.SetGlobalFunction("FlipScreen", new Action(FlipScreen));
engine.SetGlobalFunction("GetScreenWidth", new Func<int>(GetScreenWidth));
engine.SetGlobalFunction("GetScreenHeight", new Func<int>(GetScreenHeight));
engine.SetGlobalFunction("Print", new Action<string>(Print));
engine.SetGlobalFunction("GarbageCollect", new Action(GarbageCollect));
engine.SetGlobalFunction("Exit", new Action(Exit));
engine.SetGlobalFunction("CreateColor", new Func<int, int, int, int, ColorInstance>(CreateColor));
engine.SetGlobalFunction("LoadImage", new Func<string, ImageInstance>(LoadImage));
engine.SetGlobalFunction("LoadSound", new Func<string, SoundInstance>(LoadSound));
engine.SetGlobalFunction("LoadSurface", new Func<string, ObjectInstance>(LoadSurface));
engine.SetGlobalFunction("LoadWindowStyle", new Func<string, WindowStyleInstance>(LoadWindowStyle));
engine.SetGlobalFunction("LoadSpriteset", new Func<string, SpritesetInstance>(LoadSpriteset));
engine.SetGlobalFunction("CreateSpriteset", new Func<int, int, int, int, int, SpritesetInstance>(CreateSpriteset));
engine.SetGlobalFunction("LoadFont", new Func<string, FontInstance>(LoadFont));
engine.SetGlobalFunction("GetSystemFont", new Func<FontInstance>(GetSystemFont));
engine.SetGlobalFunction("GetSystemWindowStyle", new Func<WindowStyleInstance>(GetSystemWindowStyle));
engine.SetGlobalFunction("GetSystemArrow", new Func<ImageInstance>(GetSystemArrow));
engine.SetGlobalFunction("GetSystemUpArrow", new Func<ImageInstance>(GetSystemUpArrow));
engine.SetGlobalFunction("GetSystemDownArrow", new Func<ImageInstance>(GetSystemDownArrow));
engine.SetGlobalFunction("Triangle", new Action<double, double, double, double, double, double, ColorInstance>(GlobalPrimitives.Triangle));
engine.SetGlobalFunction("GradientTriangle", new Action<ObjectInstance, ObjectInstance, ObjectInstance, ColorInstance, ColorInstance, ColorInstance>(GlobalPrimitives.GradientTriangle));
engine.SetGlobalFunction("Rectangle", new Action<double, double, double, double, ColorInstance>(GlobalPrimitives.Rectangle));
engine.SetGlobalFunction("OutlinedRectangle", new Action<double, double, double, double, ColorInstance, double>(GlobalPrimitives.OutlinedRectangle));
engine.SetGlobalFunction("GradientRectangle", new Action<double, double, double, double, ColorInstance, ColorInstance, ColorInstance, ColorInstance>(GlobalPrimitives.GradientRectangle));
engine.SetGlobalFunction("OutlinedCircle", new Action<double, double, double, ColorInstance, double>(GlobalPrimitives.OutlinedCircle));
engine.SetGlobalFunction("GradientCircle", new Action<double, double, double, ColorInstance, ColorInstance, bool>(GlobalPrimitives.GradientCircle));
engine.SetGlobalFunction("FilledCircle", new Action<double, double, double, ColorInstance>(GlobalPrimitives.FilledCircle));
engine.SetGlobalFunction("Line", new Action<double, double, double, double, ColorInstance>(GlobalPrimitives.Line));
engine.SetGlobalFunction("LineSeries", new Action<ArrayInstance, ColorInstance>(GlobalPrimitives.LineSeries));
engine.SetGlobalFunction("Point", new Action<double, double, ColorInstance>(GlobalPrimitives.Point));
engine.SetGlobalFunction("PointSeries", new Action<ArrayInstance, ColorInstance>(GlobalPrimitives.PointSeries));
engine.SetGlobalFunction("Polygon", new Action<ArrayInstance, ColorInstance, bool>(GlobalPrimitives.Polygon));
engine.SetGlobalFunction("GradientLine", new Action<double, double, double, double, ColorInstance, ColorInstance>(GlobalPrimitives.GradientLine));
engine.SetGlobalFunction("ApplyColorMask", new Action<ColorInstance>(GlobalPrimitives.ApplyColorMask));
engine.SetGlobalFunction("CreateSurface", new Func<int, int, ColorInstance, ObjectInstance>(CreateSurface));
engine.SetGlobalFunction("GrabImage", new Func<int, int, int, int, ImageInstance>(GrabImage));
engine.SetGlobalFunction("GrabSurface", new Func<int, int, int, int, SurfaceInstance>(GrabSurface));
engine.SetGlobalFunction("SetFrameRate", new Action<int>(SetFrameRate));
engine.SetGlobalFunction("GetFrameRate", new Func<int>(GetFrameRate));
engine.SetGlobalFunction("GetTime", new Func<double>(GetTime));
engine.SetGlobalFunction("BlendColors", new Func<ColorInstance, ColorInstance, ColorInstance>(BlendColors));
engine.SetGlobalFunction("BlendColorsWeighted", new Func<ColorInstance, ColorInstance, double, ColorInstance>(BlendColorsWeighted));
engine.SetGlobalFunction("IsKeyPressed", new Func<int, bool>(GlobalInput.IsKeyPressed));
engine.SetGlobalFunction("IsAnyKeyPressed", new Func<bool>(GlobalInput.IsAnyKeyPressed));
engine.SetGlobalFunction("IsMouseButtonPressed", new Func<int, bool>(GlobalInput.IsMouseButtonPressed));
engine.SetGlobalFunction("GetMouseWheelEvent", new Func<int>(GlobalInput.GetMouseWheelEvent));
engine.SetGlobalFunction("GetNumMouseWheelEvents", new Func<int>(GlobalInput.GetNumMouseWheelEvents));
engine.SetGlobalFunction("IsJoystickButtonPressed", new Func<int, int, bool>(GlobalInput.IsJoystickButtonPressed));
engine.SetGlobalFunction("GetJoystickAxis", new Func<int, int, double>(GlobalInput.GetJoystickAxis));
engine.SetGlobalFunction("GetNumJoystickAxes", new Func<int, int>(GlobalInput.GetNumJoystickAxes));
engine.SetGlobalFunction("AreKeysLeft", new Func<bool>(GlobalInput.AreKeysLeft));
engine.SetGlobalFunction("GetKey", new Func<int>(GlobalInput.GetKey));
engine.SetGlobalFunction("GetKeyString", new Func<int, bool, string>(GlobalInput.GetKeyString));
engine.SetGlobalFunction("SetTalkActivationKey", new Action<int>(GlobalInput.SetTalkActivationKey));
engine.SetGlobalFunction("SetTalkActivationButton", new Action<int>(GlobalInput.SetTalkActivationButton));
engine.SetGlobalFunction("GetTalkActivationKey", new Func<int>(GlobalInput.GetTalkActivationKey));
engine.SetGlobalFunction("GetTalkActivationButton", new Func<int>(GlobalInput.GetTalkActivationButton));
engine.SetGlobalFunction("GetMouseX", new Func<int>(GlobalInput.GetMouseX));
engine.SetGlobalFunction("GetMouseY", new Func<int>(GlobalInput.GetMouseY));
engine.SetGlobalFunction("SetMouseX", new Action<int>(GlobalInput.SetMouseX));
engine.SetGlobalFunction("SetMouseY", new Action<int>(GlobalInput.SetMouseY));
engine.SetGlobalFunction("SetMousePosition", new Action<int, int>(GlobalInput.SetMousePosition));
engine.SetGlobalFunction("BindKey", new Action<int, string, string>(GlobalInput.BindKey));
engine.SetGlobalFunction("UnbindKey", new Action<int>(GlobalInput.UnbindKey));
engine.SetGlobalFunction("GetNumJoysticks", new Func<int>(GlobalInput.GetNumJoySticks));
engine.SetGlobalFunction("GetNumJoystickButtons", new Func<int, int>(GlobalInput.GetNumJoyStickButtons));
engine.SetGlobalFunction("OpenFile", new Func<string, FileInstance>(OpenFile));
engine.SetGlobalFunction("OpenRawFile", new Func<string, bool, RawFileInstance>(OpenRawFile));
engine.SetGlobalFunction("CreateByteArray", new Func<int, ByteArrayInstance>(CreateByteArray));
engine.SetGlobalFunction("CreateByteArrayFromString", new Func<string, ByteArrayInstance>(CreateByteArrayFromString));
engine.SetGlobalFunction("CreateStringFromByteArray", new Func<ByteArrayInstance, string>(CreateStringFromByteArray));
engine.SetGlobalFunction("CreateDirectory", new Action<string>(CreateDirectory));
engine.SetGlobalFunction("GetDirectoryList", new Func<string, ArrayInstance>(GetDirectoryList));
engine.SetGlobalFunction("GetFileList", new Func<string, ArrayInstance>(GetFileList));
engine.SetGlobalFunction("RemoveDirectory", new Action<string>(RemoveDirectory));
engine.SetGlobalFunction("RemoveFile", new Action<string>(RemoveFile));
engine.SetGlobalFunction("Rename", new Func<string, string, bool>(Rename));
engine.SetGlobalFunction("HashFromFile", new Func<string, bool, string>(HashFromFile));
engine.SetGlobalFunction("HashByteArray", new Func<ByteArrayInstance, bool, string>(HashByteArray));
engine.SetGlobalFunction("CreateStringFromCode", new Func<int, string>(CreateStringFromCode));
engine.SetGlobalFunction("SetScaled", new Action<bool>(SetScaled));
engine.SetGlobalFunction("GetGameList", new Func<ArrayInstance>(GetGameList));
engine.SetGlobalFunction("SetClippingRectangle", new Action<int, int, int, int>(SetClippingRectangle));
engine.SetGlobalFunction("GetClippingRectangle", new Func<ObjectInstance>(GetClippingRectangle));
engine.SetGlobalFunction("ListenOnPort", new Func<int, object>(ListenOnPort));
engine.SetGlobalFunction("OpenAddress", new Func<string, int, object>(OpenAddress));
engine.SetGlobalFunction("GetLocalAddress", new Func<string>(GetLocalAddress));
engine.SetGlobalFunction("GetLocalName", new Func<string>(GetLocalName));
engine.SetGlobalFunction("SettFullScreen", new Action<bool>(SetFullScreen));
engine.SetGlobalFunction("IsFullScreen", new Func<bool>(IsFullScreen));
engine.SetGlobalFunction("LineIntersects", new Func<ObjectInstance, ObjectInstance, ObjectInstance, ObjectInstance, bool>(LineIntersects));
engine.SetGlobalValue("BinaryHeap", new BinHeapConstructor(engine));
//.........这里部分代码省略.........
示例15: BindToEngine
public static void BindToEngine(ScriptEngine engine)
{
engine.SetGlobalFunction("MapEngine", new Action<string, int>(MapEngine));
engine.SetGlobalFunction("ExitMapEngine", new Action(ExitMapEngine));
engine.SetGlobalFunction("ChangeMap", new Action<string>(ChangeMap));
engine.SetGlobalFunction("IsMapEngineRunning", new Func<bool>(IsMapEngineRunning));
engine.SetGlobalFunction("SetCameraX", new Action<int>(SetCameraX));
engine.SetGlobalFunction("SetCameraY", new Action<int>(SetCameraY));
engine.SetGlobalFunction("GetCameraX", new Func<int>(GetCameraX));
engine.SetGlobalFunction("GetCameraY", new Func<int>(GetCameraY));
engine.SetGlobalFunction("SetUpdateScript", new Action<string>(SetUpdateScript));
engine.SetGlobalFunction("SetRenderScript", new Action<string>(SetRenderScript));
engine.SetGlobalFunction("SetDelayScript", new Action<int, string>(SetDelayScript));
engine.SetGlobalFunction("SetLayerRenderer", new Action<int, string>(SetLayerRenderer));
engine.SetGlobalFunction("GetMapEngineFrameRate", new Func<int>(GetMapEngineFrameRate));
engine.SetGlobalFunction("SetMapEngineFrameRate", new Action<int>(SetMapEngineFrameRate));
engine.SetGlobalFunction("AttachInput", new Action<string>(AttachInput));
engine.SetGlobalFunction("AttachCamera", new Action<string>(AttachCamera));
engine.SetGlobalFunction("DetachInput", new Action(DetachInput));
engine.SetGlobalFunction("DetachCamera", new Action(DetachCamera));
engine.SetGlobalFunction("GetInputPerson", new Func<string>(GetInputPerson));
engine.SetGlobalFunction("GetCameraPerson", new Func<string>(GetCameraPerson));
engine.SetGlobalFunction("IsInputAttached", new Func<bool>(IsInputAttached));
engine.SetGlobalFunction("IsCameraAttached", new Func<bool>(IsCameraAttached));
engine.SetGlobalFunction("UpdateMapEngine", new Action(UpdateMapEngineHandle));
engine.SetGlobalFunction("RenderMap", new Action(RenderMapHandle));
engine.SetGlobalFunction("GetTileWidth", new Func<int>(GetTileWidth));
engine.SetGlobalFunction("GetTileHeight", new Func<int>(GetTileHeight));
engine.SetGlobalFunction("GetLayerWidth", new Func<int, int>(GetLayerWidth));
engine.SetGlobalFunction("GetLayerHeight", new Func<int, int>(GetLayerHeight));
engine.SetGlobalFunction("SetDefaultMapScript", new Action<int, object>(SetDefaultMapScript));
engine.SetGlobalFunction("CallDefaultMapScript", new Action<int>(CallDefaultMapScript));
engine.SetGlobalFunction("CallMapScript", new Action<int>(CallMapScript));
engine.SetGlobalFunction("GetCurrentMap", new Func<string>(GetCurrentMap));
engine.SetGlobalFunction("GetTile", new Func<int, int, int, int>(GetTile));
engine.SetGlobalFunction("SetTile", new Action<int, int, int, int>(SetTile));
engine.SetGlobalFunction("SetTileImage", new Action<int, ImageInstance>(SetTileImage));
engine.SetGlobalFunction("GetTileImage", new Func<int, ImageInstance>(GetTileImage));
engine.SetGlobalFunction("GetNextAnimatedTile", new Func<int, int>(GetNextAnimatedTile));
engine.SetGlobalFunction("GetNumTiles", new Func<int>(GetNumTiles));
engine.SetGlobalFunction("GetNumLayers", new Func<int>(GetNumLayers));
engine.SetGlobalFunction("GetLayerName", new Func<int, string>(GetLayerName));
engine.SetGlobalFunction("GetTileName", new Func<int, string>(GetTileName));
engine.SetGlobalFunction("GetTileDelay", new Func<int, int>(GetTileDelay));
engine.SetGlobalFunction("SetLayerVisible", new Action<int, bool>(SetLayerVisible));
engine.SetGlobalFunction("SetLayerReflective", new Action<int, bool>(SetLayerReflective));
engine.SetGlobalFunction("MapToScreenX", new Func<int, int, int>(MapToScreenX));
engine.SetGlobalFunction("MapToScreenY", new Func<int, int, int>(MapToScreenY));
engine.SetGlobalFunction("ScreenToMapX", new Func<int, int, int>(ScreenToMapX));
engine.SetGlobalFunction("ScreenToMapY", new Func<int, int, int>(ScreenToMapY));
engine.SetGlobalFunction("IsTriggerAt", new Func<double, double, int, bool>(IsTriggerAt));
engine.SetGlobalFunction("ExecuteTrigger", new Action<double, double, int>(ExecuteTrigger));
engine.SetGlobalFunction("SetColorMask", new Action<ColorInstance, int>(SetColorMask));
engine.SetGlobalFunction("AreZonesAt", new Func<int, int, int, bool>(AreZonesAt));
engine.SetGlobalFunction("ExecuteZones", new Action<int, int, int>(ExecuteZones));
engine.SetGlobalFunction("ExecuteZoneScript", new Action<int>(ExecuteZoneScript));
engine.SetGlobalFunction("GetZoneHeight", new Func<int, int>(GetZoneHeight));
engine.SetGlobalFunction("GetZoneWidth", new Func<int, int>(GetZoneWidth));
engine.SetGlobalFunction("GetZoneLayer", new Func<int, int>(GetZoneLayer));
engine.SetGlobalFunction("GetZoneX", new Func<int, int>(GetZoneX));
engine.SetGlobalFunction("GetZoneY", new Func<int, int>(GetZoneY));
engine.SetGlobalFunction("GetNumZones", new Func<int>(GetNumZones));
engine.SetGlobalFunction("IsLayerReflective", new Func<int, bool>(IsLayerReflective));
engine.SetGlobalFunction("IsLayerVisible", new Func<int, bool>(IsLayerVisible));
engine.SetGlobalFunction("ReplaceTilesOnLayer", new Action<int, int, int>(ReplaceTilesOnLayer));
engine.SetGlobalFunction("GetCurrentZone", new Func<int>(GetCurrentZone));
}