Book a Demo

Author Topic: Modelling C# calculated properties  (Read 3607 times)

DrLik

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Modelling C# calculated properties
« on: October 14, 2005, 12:55:53 am »
Hi,
I need to model calculated properties (properties without 1:1 referenced atribute) on my C# classes.
The only way I found so far is to add new method with proper return value and without parameters and mark it with stereotype "property". This stereotype is not present in stereotype list, so this does not seem to be the best idea.
Generated code from this hand-made property has <unknown> instead of attribute name:

public int Calculated {
get{
return <unknown>;
}
set{
<unknown> = value;
}
}

It is possible to add tagged value attribute_name with value which I need instead of <unknown>, but this does not seem to be good way too...
Does any better/recommended way how to model calculated properties exist?
Thanks,

Zdenek D.



thomaskilian

  • Guest
Re: Modelling C# calculated properties
« Reply #1 on: October 14, 2005, 02:51:36 am »
Not sure whether you already know that: In the Attributes window there is a checkmark "Property" that will create getter/setter accordingly.

DrLik

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Modelling C# calculated properties
« Reply #2 on: October 14, 2005, 02:56:36 am »
Yes, creation property from existing attribute works well. But I need to create property which does not have any attribute related (property calculated from two attributes etc.).  
So I need to create property without attribute (so I cannot use the Property checkmark on attribute) and need any idea what is the best way...  ;)

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Modelling C# calculated properties
« Reply #3 on: October 14, 2005, 08:03:28 am »
You'll have to look at the Code Generation templates and roll your own customized output. It's not quite a scripting langauge (I sometimes wish it were!) but you should be able to do what you've specified very easily.

A couple of things to note:
1) Code Generation templates are stored within model. You'll either have to add them to the 'base' EA model or export them to XML and import them per new model created.
2) Code Generation template fixes/updates will not override your custom template. So any bugs/issues/improvements will have to be manually added to your custom ones.

Best of luck!