Book a Demo

Author Topic: Help with property attribute! (C#)  (Read 3912 times)

PedroLuz

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Help with property attribute! (C#)
« on: June 03, 2008, 08:42:27 am »
Hello there! Well, i simply couldn't find the code template for properties in C#, there's no error at all, but the way that the code is generated is just freaking me out x.x (although is the default way...)

Default way:

public int ID{
            get{
                  return _ID;
            }
            set{]

                  _ID = value;
            }
      }


I wanted the code to be like that:

public int ID
        {
            get
                {
                  return _ID;
            }
            set
                {
                  _ID = value;
            }
      }



Can anybody tell me where can i find this template? thanks for the attention!  :)
« Last Edit: June 03, 2008, 08:42:43 am by AngelDragonwake »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Help with property attribute! (C#)
« Reply #1 on: June 03, 2008, 08:50:02 am »
Pedro,

If memory serves, you need to look up the PI macro. [It has nothing to do with the Greek letter; it's just called that.]

Play around with it, and you should be able to get what you want. There are a (very) few posts in the forum (none recently I think) that have some specific code, but you will probably be able to figure it out yourself.

HTH, David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Help with property attribute! (C#)
« Reply #2 on: June 03, 2008, 10:08:10 am »
You're looking at stereotype overrides for Operation templates.  (Feature stereotype = property).

The gap between ID and the first brace will be generated by the PI at the Operation template itself.  (From memory there is no override for that by default)

The rest of what you're interested in is in the Operation Body override for property.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Help with property attribute! (C#)
« Reply #3 on: June 03, 2008, 10:21:55 pm »
Quote
You're looking at stereotype overrides for Operation templates.  (Feature stereotype = property).

The gap between ID and the first brace will be generated by the PI at the Operation template itself.  (From memory there is no override for that by default)

The rest of what you're interested in is in the Operation Body override for property.
Thanks Simon,

Does that mean you can edit a copy of the template to change the first one? Or is it absolutely fixed in stone?

Following your advice will cause the others will fall into place nicely, of course.

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Help with property attribute! (C#)
« Reply #4 on: June 04, 2008, 07:57:29 am »
Whenever you make a change to a template and save it, EA saves a copy which EA will use in preference to the original.

The stereotype overrides allow a different template to be used based on the stereotype of the element in context.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Help with property attribute! (C#)
« Reply #5 on: June 04, 2008, 09:35:23 am »
That's fine Simon,

What I really wanted to know was whether creating a custom template would allow us to change the gap between the ID and the first brace. Or is this "no override" situation absolute?

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Help with property attribute! (C#)
« Reply #6 on: June 04, 2008, 01:48:57 pm »
Sorry, I misunderstood your question.

Almost nothing is set in stone when doing a straight generate.  When doing a synchronize a few more things are (like parsed names matching model names).

I haven't tested this, but it should give you the right idea.
Code: [Select]
%OperationNotes%
%if opStereotype!="property" and opStereotype!="indexer" and opStereotype!="event"%
%if elemType == "Interface" or opTag:"delegate" == "true" or opAbstract == "T" or opTag:"extern" == "true"%
%PI=""%
%endIf%
%endIf%
%OperationDeclaration%
%OperationBody%

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Help with property attribute! (C#)
« Reply #7 on: June 04, 2008, 08:57:54 pm »
Thanks Simon. It looks pretty good.
No, you can't have it!