[Ironruby-core] How to fire IronRuby Method from C#

Ivan Porto Carrero ivan at flanders.co.nz
Tue Jun 9 16:39:52 EDT 2009


var operations = engine.CreateOperations();
operations.InvokeMember(rubyPerson, "greet");

http://github.com/casualjim/ironrubymvc/blob/ef59166eb4e5e6b06b9d90abf95d637c2126e5ed/IronRubyMvc/Core/RubyEngine.cs#L116
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Tue, Jun 9, 2009 at 10:20 PM, Mohammad Azam <lists at ruby-forum.com> wrote:

> Hi,
>
> I am returning an IronRuby object to C#. It is returned as a RubyClass
> object. I can debug and see that it also has greet() method attached to
> it but I am having difficulty in calling the greet() method from C#.
> Here is the code.
>
>  var scriptingRuntime = IronRuby.Ruby.CreateRuntime();
>            var engine = scriptingRuntime.GetEngine("rb");
>
>            RubyObject rubyPerson = ((RubyObject)engine.Execute(@"
>            class Person
>
>            def greet()
>            puts 'hello world'
>            end
>
>            end
>
>            def getPerson()
>            return Person.new
>            end
>
>            getPerson()
>            "));
>
>            RubyClass rubyPersonClass = rubyPerson.ImmediateClass;
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090609/9d5ff2c4/attachment.html>


More information about the Ironruby-core mailing list