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# field in a model (C# code)
  
Modeling a C# field in a model (C# code)
A C# field is modeled through a Modeler Attribute or Role:
Use a Role when the type of the field is a class, struct or interface.
Use an Attribute when the type of the field is not a class, struct or interface.
To model a C# field through an attribute in a model:
1. In the model, right-click the Class, Data Type or Signal that models the element that is to own the field, point to New, and then click Attribute.
2. Type the name of the field.
3. Open the Attribute's Property Pages, and then click the Options tab.
4. If you want to generate a static field, select the On Class option.
5. If you want to generate a read-only field, select the Read Only check box.
6. On the Data Type tab, click the Select button, and then select the item that is to be the type of the field.
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# Field» stereotype.
7. In the Default box, type the default value of the field, and then set the other standard properties of the Attribute as required.
8. If you want to specify C# specific information, such as modifiers, attributes and actual parameters for a generic type:
a. Apply the «C# Field» stereotype to the Attribute.
For information about applying Stereotypes to an item, click here Applying a stereotype to a model item
b. On the Attribute's Property Pages, click the C# Field tab.
c. If the type of the field 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# Field» stereotype.
For more information about the available Tag Definitions, click here Attribute mapping
For information about setting the tagged value of a Tag Definition, click here Setting a tagged value for an applied tag definition
d. Set the other tagged values of the Tag Definitions as required.
To model a C# field through a role in a model:
1. On a Class Diagram, from the Class, Data Type or Signal that is to own the field, create an Association to the Class, Data Type, Interface or Signal that is to be the type of the field.
2. In the Packages pane, expand the Class, Data Type or Signal that is to own the field, and locate the Role you have created through the Association.
3. Set the name of the Role to that of the field you want to create.
4. Open the Role's Property Pages, and then click the Options tab.
5. If you want to generate a static field, select the On Class option.
6. If you want to generate a read-only field, select the Read Only check box.
7. In the Default box, type the default value of the field, and then set the other standard properties of the Role as required.
8. If you want to specify C# specific information, such as modifiers, attributes and actual parameters for a generic type:
a. Apply the «C# Field» stereotype to the Role.
b. On the Role's Property Pages, click the C# Field tab.
c. If the type of the field 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# Field» stereotype.
For more information about the available Tag Definitions, click here Association mapping
For information about setting the tagged value of a Tag Definition, click here Setting a tagged value for an applied tag definition
d. Set the other tagged values of the Tag Definitions as required.