Generating, visualizing, editing and updating code

 

Generating C# code

There are two methods of generating C# code on a package or a class:

·         Through the  "Generate" icon in the toolbar on a package, class or component (Figure 33)

·         Through the "C# Developer/Generate" command from the context menu on a generation work product belonging to a package or a class

 

Figure 33. Generating code by using the "Generate" icon in the toolbar

 

Steps:

1.      Select the package in the explorer.

2.      In the toolbar, click on the  "Generate" icon.  If no generation work product already exists for the selected package, this is automatically created.

 

 

Visualizing generated C# code

There are two methods of visualizing generated C# code:

·         through the  "Visualize" icon in the toolbar on a class for which C# code has been generated

·         through the "C# Developed/Visualize the code" command, available in the context menu on a generation work product belonging to a class (Figure 34)

 

Figure 34. Visualizing code through the "C# Developer/Visualize the code" command

 

Steps:

1.      Right-click on the C# generation work product belonging to the class whose generated code you want to visualize.

2.      In the context menu, run the "C# Developer/Visualize the code" command.

 

A window like the one shown in Figure 35 then appears.

 

Figure 35. The "Visualizing the generated file" window

 

 

Editing generated C# code

There are two methods of editing generated C# code:

·         through the  "Edit" icon in the toolbar on a class for which C#
code has been generated

·         through the "C# Developer/Edit" command, available in the context menu which is accessed by right-clicking on a generation work product belonging to a class (Figure 36)

 

Figure 36. Launching code edition through the "C# Developer/Edit" command

 

Steps:

1.      Right-click on the C# generation work product belonging to the class whose generated code you want to edit.

2.      In the context menu, run the "C# Developer/Edit" command.

 

The generated code is then displayed in the editor defined by the "Command for invoking external editor" parameter, as shown in Figure 37.

 

Figure 37. The generated code edited in WordPad

 

 

Updating the model with modified C# code

The C# code associated to a model's class can also be modified outside Objecteering (including the code outside the zones surrounded by markers). The model can be then updated, to incorporate these changes.


To update generated C# code, the "C# Developer/Update" command is used (available in the context menu on a generation work product belonging to a package or a class).

 

Figure 38. Launching the update of generated code through the "C# Developer/Update" command

 

Steps:

1.      In the explorer, right-click on the package whose code you wish to update.

2.      Run the "C# Developer/Update" command from the context menu.