Question

How can I invoke overloaded generic method in IronRuby?

I have a .NET class with the following methods. (Take note that the methods are static)

Factory.cs
----
public static T CreateService<T>()
public static T CreateService<T>(string serviceName)

ironruby_sample.rb
----
service = Factory.create_service[ISomeService]

=> produces error "wrong arguments"

BTW, I'm using IronRuby 0.5.

Was it helpful?

Solution

Factory.method(:create_service).of(System::String).call(serviceName)

You don't have to specify the argument IronRuby will select the overload automatically. You have to grab the method and then give it (a) type parameter(s). Next you pass the arguments to the call method

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top