Book a Demo

Author Topic: C# - event keyword  (Read 4079 times)

KFTL

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
C# - event keyword
« on: February 12, 2003, 08:12:33 am »
What must be done in a class model to have EA generate the C# event keyword?  Is it possible?


DMT

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: C# - event keyword
« Reply #1 on: June 03, 2003, 07:30:23 am »
I'd be interested to know if this is a feature that's coming along as well.  If you reverse-engineer a C# class with events, it blows away the name of the event when creating the attribute on the class.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: C# - event keyword
« Reply #2 on: June 03, 2003, 06:16:10 pm »
Hi,

KFTL: Currently EA does notgenerate the event keyword for C#.  This will be possible with the release of the code generation templates (hopefully within the next week or so).

DMT:  EA's C# parser doesn't currently recognise the the event keyword.  We are modifying it to recognise both event accessors and event field declarations.   This will (hopefully) be incorporated into Build 614.

Regards,
Ben

DMT

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: C# - event keyword
« Reply #3 on: June 05, 2003, 05:43:49 am »
Thanks, Benc!

Now the next question is, will the "event" keyword be plopped in if I use the <<event>> stereotype on an attribute when I forward-engineer the code in C#?

Thanks!
Dave

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: C# - event keyword
« Reply #4 on: June 06, 2003, 12:11:42 am »
Yes that's the idea... you'll be able override the default code templates for methods and attributes based on their stereotype.  So for an attribute that is stereotyped <<event>> the code template will produce something
like:

event SomeDelegate OnSomeAction;

Similarly for a method stereotyped with <<event>>, the template would be overriden to generate something like:

event SomeDelegate OnSomeAction {
 add {
 _OnSomeAction += value;
 }
 remove {
 _OnSomeAction -= value;
 }
}

Hopefully this will prove useful.

Regards,
Ben