Book a Demo

Author Topic: How to add a Tagged Value to Connector / Operation  (Read 3586 times)

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
How to add a Tagged Value to Connector / Operation
« on: June 29, 2010, 06:37:15 pm »
Hi everyone
i try to add Tagged Values to Connectors and to Operations.
For some reason it does not work.
Adding Tagged Values to Elements works well.
the same code leads to an exception for Cons and Ops.

EA.TaggedValue tag=EA.TaggedValue)newObject.TaggedValues.AddNew("bound", "true");

or

foreach(EA.TaggedValue tag in link.TaggedValues) {
                    System.Windows.Forms.MessageBox.Show(tag.Name);
                }

exception as well.

In EA Help it says:

"The following model components can use the Tagged Values window as a convenient way to quickly view and modify Tagged Values:"

Operations : Owned properties only.
Connectors : Owned properties only.
Elements : Elements display their own Tagged Values along with any inherited values

I dont know exactly what is meant whith that.. :/

Stao
 

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13517
  • Karma: +573/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add a Tagged Value to Connector / Opera
« Reply #1 on: June 29, 2010, 10:07:02 pm »
Stao,

Lookup the definition of the EA.Collection.Addnew operation.
"true" is not a type of an element to add. Should be something like "TaggedValue" or "ConnectorTag" or something like that.

Geert

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: How to add a Tagged Value to Connector / Opera
« Reply #2 on: June 30, 2010, 11:03:06 am »
Stao,
 This should work in most cases, are you missing a Update (newObject.Update).

Please refer to the "Method Lifecycle Example" script supplied with EA8.0 which demonstrates adding, iterating and deleting tagged values to a method.

Same applies to connector and roles too.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to add a Tagged Value to Connector / Opera
« Reply #3 on: June 30, 2010, 06:32:27 pm »
solved.
elements have TaggedValues
methods have MethodTags
connectors have ConnectorTags.

so it has to be

foreach(EA.ConnectorTag tag in link.TaggedValues) {
                   System.Windows.Forms.MessageBox.Show(tag.Name);
}

@ Geert

Value and Name of the Tagged Value (ConTag.. MethodTag)
can be everything. Has to be a String