|
|
Class diagram specs |
|
|
\ Нет новой строки в конце файла |
|
|
[Original mermaid js class diagram documentation](https://mermaid-js.github.io/mermaid/#/classDiagram)
|
|
|
|
|
|
> "In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects." Wikipedia
|
|
|
|
|
|
To create a class diagram call `Create` method of `ClassDiagram` class
|
|
|
```c#
|
|
|
var diagram = ClassDiagram.Create(Orientation.RightToLeft);
|
|
|
```
|
|
|
|
|
|
## Classes
|
|
|
### Definition
|
|
|
```c#
|
|
|
var typeName = new TypeName("List", "int[]");
|
|
|
var listOfIntArrays = diagram.AddClass(typeName, "My list annotation", "customCssClass");
|
|
|
```
|
|
|
### Properties
|
|
|
Examples: define property `public abstract List<decimal> Foo { ... }`
|
|
|
use this
|
|
|
```c#
|
|
|
myClass.AddProperty(
|
|
|
"Foo",
|
|
|
new TypeName("List", "decimal"),
|
|
|
Visibility.Abstract | Visibility.Public
|
|
|
);
|
|
|
```
|
|
|
### Functions
|
|
|
Example: define method `private static decimal Average(decimal[] values)`
|
|
|
```c#
|
|
|
myClass.AddFunction(
|
|
|
"Average",
|
|
|
new TypeName("decimal", null),
|
|
|
Visibility.Static | Visibility.Private,
|
|
|
new FunctionArgument(
|
|
|
"values",
|
|
|
new TypeName("decimal[]", null)))
|
|
|
```
|
|
|
## Relations
|
|
|
```c#
|
|
|
diagram.Relation(
|
|
|
// related classes
|
|
|
firstClass,
|
|
|
secondClass,
|
|
|
|
|
|
// first class relation
|
|
|
Relationship.Aggregation,
|
|
|
Cardinality.Many,
|
|
|
|
|
|
// second class relation
|
|
|
Relationship.Composition,
|
|
|
Cardinality.ZeroToN,
|
|
|
|
|
|
// relation link style and text
|
|
|
RelationLink.Solid,
|
|
|
"SomeLable");
|
|
|
```
|
|
|
|
|
|
## Interaction
|
|
|
### Callbacks
|
|
|
```c#
|
|
|
myClass.SetCallback("alert", "CALLBACK TOOLTIP");
|
|
|
```
|
|
|
|
|
|
### Links
|
|
|
```c#
|
|
|
myClass.SetLink(new Uri("https://github.com"), "github toolTIP");
|
|
|
```
|
|
|
|
|
|
## Generate markdown syntax
|
|
|
```c#
|
|
|
string markdownSyntax = diagram.Render();
|
|
|
``` |
|
|
\ Нет новой строки в конце файла |