Forum: IronRuby Typeof ??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3a9ff49a9e689dcbfc8242f05180cc31?d=identicon&s=25 Orion Edwards (Guest)
on 2009-03-05 23:47
(Received via mailing list)
Having another go at some WCF stuff again.
I have a C# method that accepts a type. I want to pass it an interface.

interface IMyInterface;
public void DoStuff( Type t );

DoStuff( typeof(IMyInterface) );

>From the ruby side, I'm importing both IMyInterface and DoStuff from C#, I
just want to call the method from ruby.

When I do this:

do_stuff( IMyInterface );

I get "can't convert Module into System::Type"

If I try pass in a class, I get the similar "can't convert Class into
System::Type"

So, is there a way to get a .NET Type from a ruby object, particularly
an
interface/module? (it is a real .NET type as it's loaded from a C# dll)

Any help is greatly appreciated. Thanks.
1e39a948a58f4569c53d971c2e120920?d=identicon&s=25 Ivan Porto carrero (casualjim)
on 2009-03-06 00:34
(Received via mailing list)
IMyInterface.to_clr_type
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-03-06 00:35
(Received via mailing list)
IMyInterface.to_clr_type should work.

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Orion Edwards
Sent: Thursday, March 05, 2009 1:59 PM
To: ironruby-core@rubyforge.org
Subject: [Ironruby-core] Typeof ??

Having another go at some WCF stuff again.

I have a C# method that accepts a type. I want to pass it an interface.

interface IMyInterface;
public void DoStuff( Type t );

DoStuff( typeof(IMyInterface) );

>From the ruby side, I'm importing both IMyInterface and DoStuff from C#, I just want to 
call the method from ruby.

When I do this:

do_stuff( IMyInterface );

I get "can't convert Module into System::Type"

If I try pass in a class, I get the similar "can't convert Class into
System::Type"

So, is there a way to get a .NET Type from a ruby object, particularly
an interface/module? (it is a real .NET type as it's loaded from a C#
dll)

Any help is greatly appreciated. Thanks.
This topic is locked and can not be replied to.