How to get to the CLR type

How do I get to the CLR type definition of a class?

I assumed that the code below would just work or at least not fail where
it
did :slight_smile:
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler, LoginControl)

That has IronRuby complaining about the wrong type of arguments and so
on.
And I figure it’s because the register_routed_event method expects a CLR
type instead of a DLR one. The only way I know to get to the same
information as typeof(RoutedEventHandler) is to create an instance and
then
calling get_type on it. Is there anoter way for that?

Cheers
Ivan

I hit send to quickly there is more

If I do pass it the correct types (which I got from creating instances)
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler.new{}.get_type,
LoginControl.new.get_type)

then I get a new error
RoutedEvent Name ‘login’ for OwnerType ‘Ruby.Classes.UserControl3$3’
already
used.

Which leads me to believe that either I’m doing it wrong or that that’s
not
supposed to happen/supported yet and I have to file a bug report :slight_smile:

Cheers
Ivan

On Sat, Jun 14, 2008 at 5:57 PM, Ivan Porto C.
[email protected]

require ‘mscorlib’
=> true
System::String.to_clr_type
=> #System::RuntimeType:0x000005c

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Friday, June 13, 2008 11:13 PM
To: [email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

I hit send to quickly there is more

If I do pass it the correct types (which I got from creating instances)
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler.new{}.get_type,
LoginControl.new.get_type)

then I get a new error
RoutedEvent Name ‘login’ for OwnerType ‘Ruby.Classes.UserControl3$3’
already used.

Which leads me to believe that either I’m doing it wrong or that that’s
not supposed to happen/supported yet and I have to file a bug report :slight_smile:

Cheers
Ivan
On Sat, Jun 14, 2008 at 5:57 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
How do I get to the CLR type definition of a class?

I assumed that the code below would just work or at least not fail where
it did :slight_smile:
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler, LoginControl)

That has IronRuby complaining about the wrong type of arguments and so
on.
And I figure it’s because the register_routed_event method expects a CLR
type instead of a DLR one. The only way I know to get to the same
information as typeof(RoutedEventHandler) is to create an instance and
then calling get_type on it. Is there anoter way for that?

Cheers
Ivan

Oh I see… When I call .to_clr_type on a type that has only been
defined in
Ruby it returns nil

class Testing; end;
=> nil
Testing.to_clr_type
=> nil
Testing.new.get_type
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 7:42 PM, Ivan Porto C.
[email protected]

System::Type.get_type_from_handle System::Type.get_type_handle(Test)
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 4:11 AM, Ivan Porto C.
[email protected]

I’m sure i tried that, but then again I tried many things. and I’m sure
I’ve
used that before too when I was playing with LightSpeed…
Thanks

On Sat, Jun 14, 2008 at 7:20 PM, Tomas M. <

Oh ok. So what’s the story going to be for XAML then? I wrote an
application in WPF but I have to resort to writing quite some bits and
pieces in C# because XAML for example don’t want to play ball when you
create a value converter in ruby not even when defining the interface.

class CharRemainingConverter

include IValueConverter

def convert(value, target_type, parameter, culture)
return Constants::CHARACTER_LIMIT - value
end

def convert_back(value, target_type, parameter, culture)
NotImplementedException.new(“The method or operation is not
implemented.”)
end

end

I have a similar experience when it comes to DependencyProperties. I
would
like to know what that story is going to around these things. Since this
applies to both WPF and Silverlight I think everything will work out
fine
and I am just too soon for this stuff? Many things come to mind to solve
the
DependencyProperties or the RoutedEvents like an
GlobalEventManagerManager
:wink: and such but unfortunately some of the building blocks
(GlobalEventHandlersStore) are internal so I’m pretty sure I shouldn’t
mess
with it if I don’t want my stuff to break in the future.

There is also an issue with ResourceDictionaries where you can’t index
into
them from IronRuby defining a method in C# that reads the dictionary
works
just fine.

I’m not ranting or complaining… just sharing my observations :slight_smile:

Cheers
Ivan

On Sun, Jun 15, 2008 at 5:36 AM, Tomas M. <

Ruby classes have no CLR type. The type you’re getting by this is shared
across multiple Ruby classes.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Letterle
Sent: Saturday, June 14, 2008 7:07 AM
To: [email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

System::Type.get_type_from_handle System::Type.get_type_handle(Test)
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 4:11 AM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
Oh I see… When I call .to_clr_type on a type that has only been
defined in Ruby it returns nil

class Testing; end;
=> nil
Testing.to_clr_type
=> nil
Testing.new.get_type
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 7:42 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
I’m sure i tried that, but then again I tried many things. and I’m sure
I’ve used that before too when I was playing with LightSpeed…
Thanks
On Sat, Jun 14, 2008 at 7:20 PM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:

require ‘mscorlib’

=> true

System::String.to_clr_type

=> #System::RuntimeType:0x000005c

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Ivan Porto C.
Sent: Friday, June 13, 2008 11:13 PM
To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

I hit send to quickly there is more

If I do pass it the correct types (which I got from creating instances)
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler.new{}.get_type,
LoginControl.new.get_type)

then I get a new error
RoutedEvent Name ‘login’ for OwnerType ‘Ruby.Classes.UserControl3$3’
already used.

Which leads me to believe that either I’m doing it wrong or that that’s
not supposed to happen/supported yet and I have to file a bug report :slight_smile:

Cheers
Ivan

On Sat, Jun 14, 2008 at 5:57 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

How do I get to the CLR type definition of a class?

I assumed that the code below would just work or at least not fail where
it did :slight_smile:
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler, LoginControl)

That has IronRuby complaining about the wrong type of arguments and so
on.
And I figure it’s because the register_routed_event method expects a CLR
type instead of a DLR one. The only way I know to get to the same
information as typeof(RoutedEventHandler) is to create an instance and
then calling get_type on it. Is there anoter way for that?

Cheers
Ivan


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

“I think everything will work out fine and I am just too soon for this
stuff?”

Yes :slight_smile: We will definitely support definitions of static classes, but
not just yet. For example, it could be that a CLR type is created for a
Ruby class that includes a CLR interface at the point the class
definition is closed first time since the interface is included. Such a
class could still be “dynamic” in Ruby (reopened, method added/changed)
but no more CLR interfaces could be added (the CLR type won’t change).
Or something like that.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Saturday, June 14, 2008 3:38 PM
To: [email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

Oh ok. So what’s the story going to be for XAML then? I wrote an
application in WPF but I have to resort to writing quite some bits and
pieces in C# because XAML for example don’t want to play ball when you
create a value converter in ruby not even when defining the interface.

class CharRemainingConverter

include IValueConverter

def convert(value, target_type, parameter, culture)
return Constants::CHARACTER_LIMIT - value
end

def convert_back(value, target_type, parameter, culture)
NotImplementedException.new(“The method or operation is not
implemented.”)
end

end

I have a similar experience when it comes to DependencyProperties. I
would like to know what that story is going to around these things.
Since this applies to both WPF and Silverlight I think everything will
work out fine and I am just too soon for this stuff? Many things come to
mind to solve the DependencyProperties or the RoutedEvents like an
GlobalEventManagerManager :wink: and such but unfortunately some of the
building blocks (GlobalEventHandlersStore) are internal so I’m pretty
sure I shouldn’t mess with it if I don’t want my stuff to break in the
future.

There is also an issue with ResourceDictionaries where you can’t index
into them from IronRuby defining a method in C# that reads the
dictionary works just fine.

I’m not ranting or complaining… just sharing my observations :slight_smile:

Cheers
Ivan
On Sun, Jun 15, 2008 at 5:36 AM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:

Ruby classes have no CLR type. The type you’re getting by this is shared
across multiple Ruby classes.

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Michael L.
Sent: Saturday, June 14, 2008 7:07 AM

To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

System::Type.get_type_from_handle System::Type.get_type_handle(Test)
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 4:11 AM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

Oh I see… When I call .to_clr_type on a type that has only been
defined in Ruby it returns nil

class Testing; end;
=> nil
Testing.to_clr_type
=> nil
Testing.new.get_type
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 7:42 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

I’m sure i tried that, but then again I tried many things. and I’m sure
I’ve used that before too when I was playing with LightSpeed…
Thanks

On Sat, Jun 14, 2008 at 7:20 PM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:

require ‘mscorlib’

=> true

System::String.to_clr_type

=> #System::RuntimeType:0x000005c

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Ivan Porto C.
Sent: Friday, June 13, 2008 11:13 PM
To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

I hit send to quickly there is more

If I do pass it the correct types (which I got from creating instances)
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler.new{}.get_type,
LoginControl.new.get_type)

then I get a new error
RoutedEvent Name ‘login’ for OwnerType ‘Ruby.Classes.UserControl3$3’
already used.

Which leads me to believe that either I’m doing it wrong or that that’s
not supposed to happen/supported yet and I have to file a bug report :slight_smile:

Cheers
Ivan

On Sat, Jun 14, 2008 at 5:57 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

How do I get to the CLR type definition of a class?

I assumed that the code below would just work or at least not fail where
it did :slight_smile:
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler, LoginControl)

That has IronRuby complaining about the wrong type of arguments and so
on.
And I figure it’s because the register_routed_event method expects a CLR
type instead of a DLR one. The only way I know to get to the same
information as typeof(RoutedEventHandler) is to create an instance and
then calling get_type on it. Is there anoter way for that?

Cheers
Ivan


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Michael L.
[Polymath Prokrammer]
http://blog.prokrams.com


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

XAML is definitely something that’s on our radar as “want improved
support”, but we don’t have any specific plans yet.

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Saturday, June 14, 2008 3:38 PM
To: [email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

Oh ok. So what’s the story going to be for XAML then? I wrote an
application in WPF but I have to resort to writing quite some bits and
pieces in C# because XAML for example don’t want to play ball when you
create a value converter in ruby not even when defining the interface.

class CharRemainingConverter

include IValueConverter

def convert(value, target_type, parameter, culture)
return Constants::CHARACTER_LIMIT - value
end

def convert_back(value, target_type, parameter, culture)
NotImplementedException.new(“The method or operation is not
implemented.”)
end

end

I have a similar experience when it comes to DependencyProperties. I
would like to know what that story is going to around these things.
Since this applies to both WPF and Silverlight I think everything will
work out fine and I am just too soon for this stuff? Many things come to
mind to solve the DependencyProperties or the RoutedEvents like an
GlobalEventManagerManager :wink: and such but unfortunately some of the
building blocks (GlobalEventHandlersStore) are internal so I’m pretty
sure I shouldn’t mess with it if I don’t want my stuff to break in the
future.

There is also an issue with ResourceDictionaries where you can’t index
into them from IronRuby defining a method in C# that reads the
dictionary works just fine.

I’m not ranting or complaining… just sharing my observations :slight_smile:

Cheers
Ivan
On Sun, Jun 15, 2008 at 5:36 AM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:

Ruby classes have no CLR type. The type you’re getting by this is shared
across multiple Ruby classes.

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Michael L.
Sent: Saturday, June 14, 2008 7:07 AM

To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

System::Type.get_type_from_handle System::Type.get_type_handle(Test)
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 4:11 AM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

Oh I see… When I call .to_clr_type on a type that has only been
defined in Ruby it returns nil

class Testing; end;
=> nil
Testing.to_clr_type
=> nil
Testing.new.get_type
=> #System::RuntimeType:0x000005c

On Sat, Jun 14, 2008 at 7:42 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

I’m sure i tried that, but then again I tried many things. and I’m sure
I’ve used that before too when I was playing with LightSpeed…
Thanks

On Sat, Jun 14, 2008 at 7:20 PM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:

require ‘mscorlib’

=> true

System::String.to_clr_type

=> #System::RuntimeType:0x000005c

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Ivan Porto C.
Sent: Friday, June 13, 2008 11:13 PM
To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] How to get to the CLR type

I hit send to quickly there is more

If I do pass it the correct types (which I got from creating instances)
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler.new{}.get_type,
LoginControl.new.get_type)

then I get a new error
RoutedEvent Name ‘login’ for OwnerType ‘Ruby.Classes.UserControl3$3’
already used.

Which leads me to believe that either I’m doing it wrong or that that’s
not supposed to happen/supported yet and I have to file a bug report :slight_smile:

Cheers
Ivan

On Sat, Jun 14, 2008 at 5:57 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:

How do I get to the CLR type definition of a class?

I assumed that the code below would just work or at least not fail where
it did :slight_smile:
@@login_event = EventManager.register_routed_event(“login”,
RoutingStrategy.bubble, RoutedEventHandler, LoginControl)

That has IronRuby complaining about the wrong type of arguments and so
on.
And I figure it’s because the register_routed_event method expects a CLR
type instead of a DLR one. The only way I know to get to the same
information as typeof(RoutedEventHandler) is to create an instance and
then calling get_type on it. Is there anoter way for that?

Cheers
Ivan


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Michael L.
[Polymath Prokrammer]
http://blog.prokrams.com


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core