小编rub*_*111的帖子

IronRuby作为.NET中的脚本语言

我想在我的.NET项目中使用IronRuby作为脚本语言(例如Lua).例如,我希望能够从Ruby脚本订阅特定事件,在宿主应用程序中触发,并从中调用Ruby方法.

我正在使用此代码来实例化IronRuby引擎:

Dim engine = Ruby.CreateEngine()
Dim source = engine.CreateScriptSourceFromFile("index.rb").Compile()
' Execute it
source.Execute()
Run Code Online (Sandbox Code Playgroud)

假设index.rb包含:

subscribe("ButtonClick", handler)
def handler
   puts "Hello there"
end
Run Code Online (Sandbox Code Playgroud)

我如何能:

  1. 使用C#方法订阅(在主机应用程序中定义)可以从index.rb中看到吗?
  2. 从宿主应用程序调用以后的处理程序方法?

.net c# ruby ironruby scripting-interface

8
推荐指数
1
解决办法
2157
查看次数

标签 统计

.net ×1

c# ×1

ironruby ×1

ruby ×1

scripting-interface ×1