# Clr events in ruby

**URL:** <https://www.ruby-forum.com/t/clr-events-in-ruby/167133>\
**Category:** IronRuby\
**Created:** [May 4, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/clr-events-in-ruby/167133 "2009-05-04T15:11:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mroths](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mroths](https://www.ruby-forum.com/u/mroths)\
**Post date:** [May 4, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/clr-events-in-ruby/167133/1 "2009-05-04T15:11:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mroths](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mroths](https://www.ruby-forum.com/u/mroths)\
**Post date:** [May 4, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/clr-events-in-ruby/167133/2 "2009-05-04T15:26:58Z")

</div>

I believe that this should work, but the name would need to be Rubified  
as “add\_my\_event”.

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Mark R.  
Sent: Monday, May 04, 2009 6:02 AM  
To: removed\_email\_address@domain.invalid  
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?

---

<div class="post-metadata">

**Author:** ![mroths](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mroths](https://www.ruby-forum.com/u/mroths)\
**Post date:** [May 4, 2009, 3:46pm UTC](https://www.ruby-forum.com/t/clr-events-in-ruby/167133/3 "2009-05-04T15:46:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mroths](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mroths](https://www.ruby-forum.com/u/mroths)\
**Post date:** [May 4, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/clr-events-in-ruby/167133/4 "2009-05-04T15:57:39Z")

</div>

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: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Mark R.  
Sent: Monday, May 04, 2009 6:46 AM  
To: removed\_email\_address@domain.invalid  
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 H.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I believe that this should work, but the name would need to be Rubified  
as “add\_my\_event”.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mark R.  
Sent: Monday, May 04, 2009 6:02 AM  
To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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?
