Author Topic: Exposing an association via a property  (Read 806 times)

wshaddix

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Exposing an association via a property
« on: June 29, 2005, 06:45:30 am »
I am modeling a simple web application written in ASP.Net and C#. I have an "AuditEvent" class that should have a property of "EventType". The "EventType" is stereotyped as an enumeration.

My question is this:
If I manually add the attribute EventType to the AuditEvent class, specifing the datatype to be of type EventType, then I can check the "property" checkbox and it will wrap the private "EventType" member with a public property. The problem is, an association relationship is not reflected in the model.

If I draw the association relationship from AuditEvent to EventType, I don't have an option (that I can find) to expose that as a property.

How do I model this correctly in EA?

pseudo code of what I want is:

namespace Test
{
 class AuditEvent
 {
    private EventType theEventType;

    public EventType AuditEventType
    {
       get {return theEventType;}
       set { theEventType = value; }
    }
 }
}

AND, I want to see the associative relationship on the class diagram.

Any help is greatly appreciated.

Wes

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6281
  • Karma: +52/-5
    • View Profile
Re: Exposing an association via a property
« Reply #1 on: June 29, 2005, 03:49:31 pm »
At the moment, you have three options. (That I can think of.)

Model both the attribute in the class and the association (and keep them in synch with each other).

Alternatively, model the association and create the property method manually.  To do this, create a method, set the stereotype to property and give it a tagged value "attribute_name" with the value being the role from the association.

Model it just with an association, and use the C# transformation to create the property for you.

Simon
Simon

support@sparxsystems.com

wshaddix

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Exposing an association via a property
« Reply #2 on: June 29, 2005, 06:18:23 pm »
I posted here before realizing I could alter the code in the source window and synch the model. When I hand coded it the way I wanted, EA implemented it as your second suggestion. Thanks for your help, I appreciate it.

Wes

legendabre

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Exposing an association via a property
« Reply #3 on: December 06, 2005, 06:24:01 am »
Has status of this changed in newer build? Can I expose association throught property in v6 (so I know whenever to buy it or to stick with current ;D )