Another Interop Question


#1

From C#, is it possible to new up an instance of an IronRuby class and
then invoke a method on it?

I.e:

var ruby = new StringBuilder();

ruby.AppendLine(“class MyClass”);
ruby.AppendLine(" def render");
ruby.AppendLine(" “Hello!”");
ruby.AppendLine(" end");
ruby.AppendLine(“end”);

var scriptEngine = Ruby.CreateEngine();

scriptEngine.Execute(ruby.ToString());

var action =
scriptEngine.CreateScriptSourceFromString(“MyClass.method(:new)”).Execute();

var o = scriptEngine.Operations.Call(action);

// how to invoke render?

Cheers,

Andrew.


#2

No worries, I’ve found what I need in Phil H.'s IronRuby view engine
sample.

Cheers,

Andrew.


#3

Cool. Now you can provide an answer when the next person asks. :slight_smile: