Chapter 17 Travailler avec C# 2.0
PowerAMC représente les événements, indexeurs et propriétés C# sous la forme d'attributs UML standard, dotés des propriétés supplémentaires suivantes :
L'exemple suivant montre la classe Button, qui contient 3 événements :
Dans l'exemple suivant, la classe Employee contient 2 propriétés. L'opération Setter a été retirée de la propriété 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;
}
}
}
Dans l'exemple suivant, la classe Person contient un attribut indexeur Item. Le paramètre utilisé pour trier la propriété est 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;
Pour créer un événement, un indexeur ou une propriété :
Pour plus d'informations sur comment créer et travailler avec des attributs, voir la section "Attributs" dans le chapitre "Construction de diagrammes structurels".
| Copyright (C) 2008. Sybase Inc. All rights reserved. |
| |