Author Topic: C# properties  (Read 1121 times)

joyce

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
C# properties
« on: December 18, 2003, 09:56:10 am »
Hi, we are using EA with c#.
We have imported some sample classes and EA correctly found the properties and stereotyped them, however it fails to see that some are read only and generically just calls them all a property.

What's wierd is if we then re-engineer code freshly to a new file from thos objects it makes proper GET/SET properties for them (however it makes get and set even if the original was read only (get only)).

If we are to make our own classes, we have no stereotype option to select property and no where to set read only as far as I can tell.

Is this a limitation or are we missing something?

=-=-=
Update: we tried just making a stereotype called "property" and somehow EA knew to generate proper property code, so the only problem remaining is how to tell it that it's read only or write only and generate only the GET or the SET and not both every time as it does now?  

(also you can't specify the private variable so it just puts <unknown> in place of that, would be nice if that's possible at design time as well).

« Last Edit: December 18, 2003, 10:11:23 am by JCardinal »

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 195
  • Karma: +0/-0
    • View Profile
Re: C# properties
« Reply #1 on: December 21, 2003, 05:03:13 pm »
Hi joyce,

You can control whether a property is read only or write only through the use of tagged values:

1. Go to the operations dialogue (F10) and select your property.

2. Go to the "Tags" tab and create a "readonly" or "writeonly" tag. Give it a non-empty value, like "1".

3. During generation, the "readonly" and "writeonly" tags are checked. (You can see this in the relevant Code Generation Templates- Cntrl+Shift+P to bring up the template editor)

The fact that these tagged values are not automatically filled in during import, is a limitation we need to address.

Note: if you are manually creating a property in the model, the property creation dialogue will fill in the read only and write only tags for you. You can bring up this diaolgue by checking the "property" checkbox on a class attribute.

I hope this explains.

Regards,
Ben

joyce

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: C# properties
« Reply #2 on: December 22, 2003, 10:03:45 am »
Ahhh...that's how you do it manually!
Thank you!