You can only reach it by adding the class as receiver.

but you can use method missing as a dispatcher:

alias :old_mm :method_missing
def method_missing(method_name, *args, &block)
   return MyCSharpClass.send(method_name, *args) if MyCSharpClass.respond_to?
method_name
   old_mn method_name, *args, &block
 end



try this in a console :)

alias :old_mm :method_missing
def method_missing(method_name, *args, &block)
   return System::Math.send(method_name, *args) if System::Math.respond_to?
method_name
   old_mn method_name, *args, &block
 end

puts pi
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Google Wave: portocarrero.i...@googlewave.com
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Fri, Nov 13, 2009 at 7:22 PM, Alexandre Mutel <li...@ruby-forum.com>wrote:

> Hi all,
> Is there any way to declare a C# static method accessible from IronRuby
> as a regular Ruby method?
> like:
> public class MyCSharpClass {
>  public static string mymethod(string test) {
>     return test + "yes";
>  }
> }
>
> in ironruby:
> puts mymethod("test")
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to