Property

To design a C# property you have to design an attribute with the <<Property>> stereotype.

When you do so, another attribute with the <<PropertyImplementation>> stereotype is automatically created, it is displayed with an underscore sign in the list of attributes. The corresponding getter and setter operations are also automatically created.

You can get rid of the implementation attribute.

If you remove both getter and setter operations, the attribute no longer has the <<Property>> stereotype.

When you define a <<Property>> attribute, the attribute changeability and the getter/setter operations are tightly related as explained in the following table:

Operations

Property attribute changeability

If you keep both getter and setter operations

Property is Changeable

If you remove the setter operation of a changeable property

Property becomes Read-only

If you remove the getter operation of a changeable property

Property becomes Write-only

On the other hand, if you modify the property changeability, operations will reflect this change, for example, if you turn a changeable property into a read-only property, the setter operation is automatically removed.

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;
    }
  }
 }

The following table lists the different property modifiers supported in PowerDesigner:

C# property modifiers

PowerDesigner equivalent

Abstract

Abstract extended attribute set to True

Extern

Extern extended attribute set to True

Override

Override extended attribute set to True

Sealed

Sealed extended attribute set to True

Unsafe

Unsafe extended attribute set to True

Virtual

Virtual extended attribute set to True