I want to use IronRuby as a scripting language (as Lua, for example) in my .NET project. For example, I want to be able to subscribe from a Ruby script to specific events, fired in the host application, and call Ruby methods from it.
I'm using this code for instantiating the IronRuby engine:
Dim engine = Ruby.CreateEngine()
Dim source = engine.CreateScriptSourceFromFile("index.rb").Compile()
' Execute it
source.Execute()
Supposing index.rb contains:
subscribe("ButtonClick", handler)
def handler
puts "Hello there"
end
How do I:
- Make C# method Subscribe (defined in host application) visible from index.rb?
- Invoke later handler method from the host application?