ClassDiagram Class

A class diagram: classes with their attributes and methods, linked by relations (inheritance, composition, association...), grouped in namespaces (Mermaid classDiagram).

public sealed class ClassDiagram : Diagram
Inheritance
Diagram ClassDiagram

Constructors

NameDescription
ClassDiagram()

ClassDiagram()

ClassDiagram.cs
public ClassDiagram()

No documentation is available.

Properties

NameDescription
ClassDefinitionsGets the styles of the CSS classes of the elements, by name (Mermaid classDef). The class default applies to every class.
ClassesGets the classes. The classes of the namespaces that are not in this list are drawn too.
DirectionGets or sets the direction of the relations. The default is DiagramDirection.TopToBottom.
HideEmptyMembersBoxGets or sets a value that indicates whether a class without members has no empty compartments (Mermaid hideEmptyMembersBox).
InterfacesGets the interfaces drawn as lollipops.
NamespacesGets the top-level namespaces.
NotesGets the notes.
RelationsGets the relations, drawn in order.

ClassDefinitions

ClassDiagram.cs

Gets the styles of the CSS classes of the elements, by name (Mermaid classDef). The class default applies to every class.

public IDictionary<string, DiagramStyle> ClassDefinitions { get; }

Gets the classes. The classes of the namespaces that are not in this list are drawn too.

public IList<ClassDiagramClass> Classes { get; }

Gets or sets the direction of the relations. The default is DiagramDirection.TopToBottom.

public DiagramDirection Direction { get; set; }

Property value

DiagramDirection

HideEmptyMembersBox

ClassDiagram.cs

Gets or sets a value that indicates whether a class without members has no empty compartments (Mermaid hideEmptyMembersBox).

public bool HideEmptyMembersBox { get; set; }

Property value

bool

Interfaces

ClassDiagram.cs

Gets the interfaces drawn as lollipops.

public IList<ClassDiagramInterface> Interfaces { get; }

Namespaces

ClassDiagram.cs

Gets the top-level namespaces.

public IList<ClassDiagramNamespace> Namespaces { get; }

Gets the notes.

public IList<ClassDiagramNote> Notes { get; }

Gets the relations, drawn in order.

public IList<ClassRelation> Relations { get; }

Property value

IList<ClassRelation>

Methods

NameDescription
AddClass(string, DiagramText?)Adds a class.
AddNamespace(string, DiagramText?)Adds a top-level namespace.
AddNote(DiagramText, ClassDiagramClass?)Adds a note.
AddRelation(ClassDiagramElement, ClassDiagramElement, ClassRelationEnd, ClassRelationEnd, DiagramText?)Adds a relation.
EnumerateNamespaces()Enumerates the namespaces and their nested namespaces, depth first.
Find(string)Finds a class or an interface by identifier, in the diagram and its namespaces.

AddClass(string, DiagramText?)

ClassDiagram.cs

Adds a class.

public ClassDiagramClass AddClass(string id, DiagramText? label = null)

Parameters

id string
The identifier, which is the name shown when there is no label.
label DiagramText?
The name shown, or null to show the identifier.

Returns

ClassDiagramClass The class.

AddNamespace(string, DiagramText?)

ClassDiagram.cs

Adds a top-level namespace.

public ClassDiagramNamespace AddNamespace(string id, DiagramText? label = null)

Parameters

id string
The identifier.
label DiagramText?
The title, or null to show the identifier.

Returns

ClassDiagramNamespace The namespace.

AddNote(DiagramText, ClassDiagramClass?)

ClassDiagram.cs

Adds a note.

public ClassDiagramNote AddNote(DiagramText text, ClassDiagramClass? @class = null)

Parameters

text DiagramText
The text.
class ClassDiagramClass?
The class the note is attached to, or null for a note alone.

Returns

ClassDiagramNote The note.

AddRelation(ClassDiagramElement, ClassDiagramElement, ClassRelationEnd, ClassRelationEnd, DiagramText?)

ClassDiagram.cs

Adds a relation.

Parameters

from ClassDiagramElement
The first element.
to ClassDiagramElement
The second element.
fromEnd ClassRelationEnd
The decoration at from.
toEnd ClassRelationEnd
The decoration at to.
label DiagramText?
The text of the relation, or null for none.

Returns

ClassRelation The relation.

EnumerateNamespaces()

ClassDiagram.cs

Enumerates the namespaces and their nested namespaces, depth first.

public IEnumerable<ClassDiagramNamespace> EnumerateNamespaces()

Returns

IEnumerable<ClassDiagramNamespace> The namespaces.

Find(string)

ClassDiagram.cs

Finds a class or an interface by identifier, in the diagram and its namespaces.

public ClassDiagramElement? Find(string id)

Parameters

id string
The identifier.

Returns

ClassDiagramElement? The element, or null when there is none.