Book a Demo

Author Topic: C# Properties  (Read 3064 times)

QHoward

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
C# Properties
« on: February 10, 2003, 05:25:16 am »
I am trying to model C# properties and am having some problems.  My main requirements are the following:

1)  I can add a Property to the model and specify whether a get accessor, set accessor or both exist.
2)  I can change this later in the model.
3)  I can add a Property to the code (with either get, set, or both).
4)  I can synchronize the model and the code.
5)  I can see in the diagrams whether the get, set, or both accessors exist (preferably with a single entry per Property on the class with a stereotype that denotes whether the Property has get, set, or both methods).

When I try to add a property to the model (issue 1 above, by selecting the property's related member variable and checking the Property checkbox and specifying whether it's read, write or both), the property always seems to be read/write and I cannot change it.  Also some parens are added to the source code that are not compilable in C#.  When I try to change a property from read/write to read-only, it doesn't seem to work (2).  I can add a property to the code (3), but it does not get tied back to the member variable.  I can also not see in the diagram whether the property is get, set, or both (5).

Am I missing something here? ???

Personally, I do not believe that the Properties should be tied to a member variable... because it is possible that the Property is not tied to a member variable at all or that it is tied to multiple member variables.

Are there any plans to fix this area in the future?

Thanks,

Quinn Howard

KFTL

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: C# Properties
« Reply #1 on: February 14, 2003, 07:45:19 am »
I can only help you with a few things.

* The read/write dialog for a property is confusing but to get around it, look at the tagged values for the property accessor.  You can add a tagged value called readonly and set it to a 1 so that it is read only.

* To tie a property to a member variable, do the same as above to get to the property's tagged value and add a value called attribute_name.  Set the value to what you want.

As far as code generation, I have found that to get around it not update the C# file, I have to save the changes to the diagram and close EA.  I then re-open the diagram and sync the model to the code.

HTH