Marc Vitalis
Marc Vitalis

Reputation: 2249

How to invoke an overloaded generic methods in IronRuby?

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.

Upvotes: 0

Views: 616

Answers (1)

Casual Jim
Casual Jim

Reputation: 1179

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

Upvotes: 3

Related Questions