Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > C# code > C# code > Reverse engineering legacy C# code > Modeling C# code in Modeler > Modeling a C# constant in a model (C# code)
  
Modeling a C# constant in a model (C# code)
A C# constant is modeled through a Modeler Attribute or Role:
Use a Role when the type of the constant is a class, struct or interface.
Use an Attribute when the type of the constant is not a class, struct or interface.
To model a C# constant through an attribute in a model:
1. In the model, right-click the Class, Data Type or Signal that is to own the constant, point to New, and then click Attribute.
2. Type the name of the constant.
3. Open the Attribute's Property Pages, click the Options tab, and then select the Read Only check box.
4. Click the Data Type tab, click the Select button, and then select the item that is to be the type of the constant.
If you want to use a delegate as a type, reference the Operation that generates the delegate through the C# Delegate Type tag definition that is applied by the «C# Constant» stereotype.
5. In the Default box, type the default value of the constant, and then set the other standard properties of the Attribute as required.
6. Apply the «C# Constant» stereotype to the Attribute.
For information about applying Stereotypes to an item, click here Applying a stereotype to a model item
7. On the Attribute's Property Pages, click the C# Constant tab.
8. If the type of the constant is a generic type, specify the type arguments through the tagged value of the C# Actual Parameters tag definition, which is applied to the Attribute through the «C# Constant» stereotype.
For information about setting the tagged value of a Tag Definition, click here Setting a tagged value for an applied tag definition.
9. Set the other tagged values of the Tag Definitions as required.
For more information about the available Tag Definitions, click here Attribute mapping
To model a C# constant through a role in a model:
1. On a Class Diagram, from the Class, Data Type or Signal that is to own the constant, create an Association to the item that is to be the type of the constant.
2. In the Packages pane, expand the Class, Data Type or Signal that is to own the constant, and locate the Role you have created.
3. Set the name of the Role to that of the constant you want to create.
4. Open the Role's Property Pages, click the Options tab, and then select the Read Only check box.
5. In the Default box, type the default value of the constant, and then set the other standard properties of the Role as required.
6. Apply the «C# Constant» stereotype to the Role.
For information about applying Stereotypes to an item, click here Applying a stereotype to a model item
7. On the Role's Property Pages, click the C# Constant tab.
8. If the type of the constant is a generic type, specify the type arguments through the tagged value of the C# Actual Parameters tag definition, which is applied to the Role through the «C# Constant» stereotype.
For information about setting the tagged value of a Tag Definition, click here Setting a tagged value for an applied tag definition
9. Set the other tagged values of the Tag Definitions as required.
For more information about the available Tag Definitions, click here Association and role mapping for C# (C# code)