Konstantin Kos
2012-Nov-20 20:25 UTC
[Ironruby-core] IronRuby hosting - executing C# method
Hi, I have some issue with hosting IronRuby in C# application. I''ve created Ruby ScriptEngine, created ScriptScope with delegate in it:> C# > scope.SetVariable("func", new Action<object>(MyMethod));but can''t execute "func" from script> Ruby > func("argument")fails with ArgumentException "wrong number of arguments (1 for 0)" but can run it by calling "invoke":> Ruby > func.invoke("argument")is it possible to execute Delegate like normal ruby function? -- Posted via http://www.ruby-forum.com/.
Orion Edwards
2012-Nov-20 20:34 UTC
[Ironruby-core] IronRuby hosting - executing C# method
No, even in pure ruby code you must use .call to execute a function stored in a variable eg: f = lambda{ |x| puts x } f.call(5) # cannot simply use f(5) This is a side effect of ruby''s syntax which allows you to call methods without brackets surrounding the arguments ______________________________________________________ Orion Edwards | Technical Leader PHONE +64 7 838 9800 | FAX +64 7 838 9801 | EMAIL orion.edwards at gallagher.co | WEB www.gallagher.co From: Konstantin Kos <lists at ruby-forum.com> To: ironruby-core at rubyforge.org Date: 21/11/2012 09:25 a.m. Subject: [Ironruby-core] IronRuby hosting - executing C# method Sent by: ironruby-core-bounces at rubyforge.org Hi, I have some issue with hosting IronRuby in C# application. I''ve created Ruby ScriptEngine, created ScriptScope with delegate in it:> C# > scope.SetVariable("func", new Action<object>(MyMethod));but can''t execute "func" from script> Ruby > func("argument")fails with ArgumentException "wrong number of arguments (1 for 0)" but can run it by calling "invoke":> Ruby > func.invoke("argument")is it possible to execute Delegate like normal ruby function? -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core ########################################################################### This e-mail is confidential and may contain information subject to legal privilege. If you are not the intended recipient please advise us of our error by return e-mail then delete this e-mail and any attached files. You may not copy, disclose or use the contents in any way. The views expressed in this e-mail may not be those of Gallagher Group Ltd or subsidiary companies thereof. ########################################################################### -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20121121/e6d6d25b/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 3465 bytes Desc: not available URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20121121/e6d6d25b/attachment.gif>
Konstantin Kos
2012-Nov-21 10:57 UTC
[Ironruby-core] IronRuby hosting - executing C# method
Orion Edwards wrote in post #1085558:> _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core??? -- Posted via http://www.ruby-forum.com/.