This content applies
to version 7.5.2 or later. You
can model C# 3.0 automatically implemented properties to generate
code. Properties in the code can also be generated in the model using
a C#-to-UML transformation.
Before you begin
To use the stereotypes required in this procedure, you must
apply the C# transformation profile to the model.
About this task
To create automatically implemented properties in the model:
Procedure
- In the Project Explorer view or diagram editor, right-click
a UML class; then click .
- Click the Stereotype tab.
- Click Apply Stereotypes, select CSharp
Property, and then click OK.
- Under Stereotype Properties, set accessors to auto.
Example
The following image shows a UML class, AClass, containing
the automatically implemented property, AnAutoProperty.
After a UML-to-C# transformation is run, the following code
is generated:
//Begin section for file AClass.cs
//TODO: Add using directives that you want preserved
//End section for file AClass.cs
using System;
// @generated
public class AClass
{
// @generated
private Object AnAutoProperty
{
get;
set;
}
}
The C# property AnAutoProperty can be used in the
C# code just like an explicitly implemented property.
What to do next
After modeling the automatically implemented property, you
can configure and run a UML-to-C# transformation to generate the C#
code.