Forum: IronRuby clr events in ruby

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.
483aefd0bfd88e15aa4383785c679c2d?d=identicon&s=25 Mark Ryall (Guest)
on 2009-05-04 15:11
(Received via mailing list)
Hi everyone,

I'm messing around with trying to create ironruby mock (actually
recorder)
implementations of various sorts of CLR type features and am struggling
with
events.

Is it currently possible to create an implementation of a CLR interface
that
contains an event?

For example

using System;

namespace ClassLibrary
{
public interface IHaveAnEvent
{
event EventHandler MyEvent;
}
}

...

class ClassWithEvent
  include ClassLibrary::IHaveAnEvent

  def initialize
    @blocks = []
  end

  def add_MyEvent
    ???? or something ????
  end
end

Is this possible or not yet available?
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2009-05-04 15:26
(Received via mailing list)
I believe that this should work, but the name would need to be Rubified
as "add_my_event".

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Mark Ryall
Sent: Monday, May 04, 2009 6:02 AM
To: ironruby-core@rubyforge.org
Subject: [Ironruby-core] clr events in ruby

Hi everyone,

I'm messing around with trying to create ironruby mock (actually
recorder) implementations of various sorts of CLR type features and am
struggling with events.

Is it currently possible to create an implementation of a CLR interface
that contains an event?

For example
using System;

namespace ClassLibrary
{
     public interface IHaveAnEvent
     {
          event EventHandler MyEvent;
     }
}

...
class ClassWithEvent
  include ClassLibrary::IHaveAnEvent

  def initialize
    @blocks = []
  end

  def add_MyEvent
    ???? or something ????
  end
end

Is this possible or not yet available?
483aefd0bfd88e15aa4383785c679c2d?d=identicon&s=25 Mark Ryall (Guest)
on 2009-05-04 15:46
(Received via mailing list)
No dice i'm afraid:
with 'add_my_event':

Snippets.scripting:0:in `add_MyEvent': undefined method `add_MyEvent'
for
IronRuby.Classes.Object$5:ClassWithEvent (NoMethodError)
        from ClassLibrary:0:in `RegisterEvent'
        from experiment1.rb:90

with 'add_MyEvent':

Snippets.scripting:0:in `add_MyEvent': The method or operation is not
implemented. (System::NotImplementedException)
        from ClassLibrary:0:in `RegisterEvent'
        from experiment1.rb:90
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2009-05-04 15:57
(Received via mailing list)
Sorry... I just looked at the source code and events are indeed not
implemented yet. I promised Tomas I'd try really really hard to finish
the typegen code this month, so you shouldn't have to wait too long.

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Mark Ryall
Sent: Monday, May 04, 2009 6:46 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] clr events in ruby

No dice i'm afraid:

with 'add_my_event':

Snippets.scripting:0:in `add_MyEvent': undefined method `add_MyEvent'
for IronRuby.Classes.Object$5:ClassWithEvent (NoMethodError)
        from ClassLibrary:0:in `RegisterEvent'
        from experiment1.rb:90

with 'add_MyEvent':

Snippets.scripting:0:in `add_MyEvent': The method or operation is not
implemented. (System::NotImplementedException)
        from ClassLibrary:0:in `RegisterEvent'
        from experiment1.rb:90

On Mon, May 4, 2009 at 11:25 PM, Curt Hagenlocher
<curth@microsoft.com<mailto:curth@microsoft.com>> wrote:

I believe that this should work, but the name would need to be Rubified
as "add_my_event".



From:
ironruby-core-bounces@rubyforge.org<mailto:ironruby-core-bounces@rubyforge.org>
[mailto:ironruby-core-bounces@rubyforge.org<mailto:ironruby-core-bounces@rubyforge.org>]
On Behalf Of Mark Ryall
Sent: Monday, May 04, 2009 6:02 AM
To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org>
Subject: [Ironruby-core] clr events in ruby



Hi everyone,

I'm messing around with trying to create ironruby mock (actually
recorder) implementations of various sorts of CLR type features and am
struggling with events.

Is it currently possible to create an implementation of a CLR interface
that contains an event?

For example

using System;



namespace ClassLibrary

{

     public interface IHaveAnEvent

     {

          event EventHandler MyEvent;

     }

}

...

class ClassWithEvent

  include ClassLibrary::IHaveAnEvent



  def initialize

    @blocks = []

  end



  def add_MyEvent

    ???? or something ????

  end

end



Is this possible or not yet available?
This topic is locked and can not be replied to.