PowerDesigner represents C# events, indexers, and properties as standard UML attributes with additional properties as follows:
Events – stereotype <<Event>> with one or two linked operations representing the add and/or remove handlers
Indexers – stereotype <<Indexer>> with one or two linked operations representing the get and/or set accessors
Properties – stereotype <<Property>> with one or two linked operations representing the get and/or set accessors. In addition, you should note that:
The visibility of the property is defined by the visibility of the get accessor operation if any, otherwise by that of the set accessor operation.
When an attribute becomes a property, an implementation attribute is automatically created to store the property value. The implementation attribute is not persistent and has a private visibility. It has the stereotype <<PropertyImplementation>> and has the same name than the property but starting with a lowercase character. If the property name already starts with a lower case its first character will be converted to uppercase.
The implementation attribute can be removed for properties not needing it. (calculated properties for instance)
If the boolean-valued extended attribute Extern is set to true, no operations should be linked to the property.
When a property declaration includes an extern modifier, the property is said to be an external property. Because an external property declaration provides no actual implementation, each of its accessor-declarations consists of a semicolon.
In the following example, class Employee contains 2 properties. The Setter operation has been removed for property TimeReport:
{
public class Employee
{
private int _Function;
private int _TimeReport;
// Property Function
private int Function
{
get
{
return _Function;
}
set
{
if (this._Function != value)
this._Function = value;
}
}
// Property TimeReport
private int TimeReport
{
get
{
return _TimeReport;
}
}
}
In the following example, class Person contains indexer attribute Item. The parameter used to sort the property is String Name:
public class Person
{
private Hashtable _childAges;
// Indexer Item
private int this[String name]
{
get
{
return (int)_ChildAges[name];
}
set
{
_ChildAges[name] = value;
}
}
}
Person someone;
someone ["Alice"] = 3;
someone ["Elvis"] = 5;