Creating C++/CLI elements

Defining attributes

CLI attributes are defined through the C++ property view of a Class, by choosing the “CLI Attribute” value in the “Class kind” field.


CLI attribute property view

This view defines all options available on the CLI Attribute definition.

Defining indexers

Indexers are modeled through a UML class with two operations, “get” and “set”, to which the <<CLI Indexer>> stereotype is added.

A class stereotyped <<CLI Indexer>> will not be generated. It will simply be used to generate C# indexer get and set signatures and bodies.

To create an indexer, simply use the creation command from the contextual menu on a class, as shown below.


The “Create CLI Indexer” command

The following is a description of indexer accessors:

Defining events and delegates

CLI events are modeled throught a UML signal to which the <<CLI Event>> stereotype is added. This signal must be a part of a class. Once a signal is stereotyped as an event, you can manage new values such as visibility (using the C++ property view) and delegate association (using Signal UML properties tab’s base field). An event must refer to a model’s delegate.

To create a CLI event, simply use the creation command from the contextual menu on a class, as shown below.


The “Create CLI Event” command

Delegates can be operations issued from delegate containers (classes stereotyped <<CLI Delegate Container>>) or delegates (operations stereotyped <<CLI Delegate>>). The related reference can be created through a drag and drop operation.

Delegate containers (classes stereotyped <<CLI Delegate Container>>) are used as containers of C# delegate types (operations stereotyped <<CLI Delegate>>). The generated delegates belong to the current parent element.

Making an operation <<CLI Delegate>> through the C++ property page will enable delegate signature and skip generation of all code notes attached to the operation.

Defining properties

CLI properties are modeled throught a UML attribute or association end, to which the <<CLI Property>> stereotype is added.

To obtain the property declaration with simplified syntax, you must not define any associated code notes (“CLI Getter Code”/“CLI Setter Code”), as if you do, a normal property will be generated.

The generator will automatically generate the get or set accessors according to which access mode has been selected.


Example of an integer property