C4Diagram Class

A C4 diagram of a software architecture: people, systems, containers and components, grouped in boundaries or deployment nodes, and the relationships between them (Mermaid C4Context, C4Container, C4Component, C4Dynamic and C4Deployment). As in Mermaid, the elements are placed in rows in the order they are declared, not by an automatic layout.

public sealed class C4Diagram : Diagram
Inheritance
Diagram C4Diagram

Constructors

NameDescription
C4Diagram()

C4Diagram()

C4Diagram.cs
public C4Diagram()

No documentation is available.

Properties

NameDescription
BoundariesGets the top-level boundaries.
BoundariesPerRowGets or sets how many boundaries a row has, at most. The default is 2 (Mermaid c4BoundaryInRow).
ElementsGets the elements that are in no boundary.
KindGets or sets the kind of the diagram. A C4DiagramKind.Dynamic diagram numbers its relationships.
RelationshipsGets the relationships, drawn in order.
ShapesPerRowGets or sets how many elements a row has, at most. The default is 4 (Mermaid c4ShapeInRow).
WrapGets or sets a value that indicates whether the texts wrap to the width of the elements. The default is true.

Boundaries

C4Diagram.cs

Gets the top-level boundaries.

public IList<C4Boundary> Boundaries { get; }

Property value

IList<C4Boundary>

BoundariesPerRow

C4Diagram.cs

Gets or sets how many boundaries a row has, at most. The default is 2 (Mermaid c4BoundaryInRow).

public int BoundariesPerRow { get; set; }

Property value

int

Elements

C4Diagram.cs

Gets the elements that are in no boundary.

public IList<C4Element> Elements { get; }

Property value

IList<C4Element>

Gets or sets the kind of the diagram. A C4DiagramKind.Dynamic diagram numbers its relationships.

public C4DiagramKind Kind { get; set; }

Property value

C4DiagramKind

Relationships

C4Diagram.cs

Gets the relationships, drawn in order.

public IList<C4Relationship> Relationships { get; }

Property value

IList<C4Relationship>

ShapesPerRow

C4Diagram.cs

Gets or sets how many elements a row has, at most. The default is 4 (Mermaid c4ShapeInRow).

public int ShapesPerRow { get; set; }

Property value

int

Gets or sets a value that indicates whether the texts wrap to the width of the elements. The default is true.

public bool Wrap { get; set; }

Property value

bool

Methods

NameDescription
AddBoundary(string, DiagramText, C4BoundaryKind)Adds a top-level boundary.
AddElement(string, C4ElementKind, DiagramText, DiagramText?)Adds an element that is in no boundary.
AddRelationship(C4Item, C4Item, DiagramText, string?)Adds a relationship.
EnumerateBoundaries()Enumerates the boundaries and their nested boundaries, depth first.
Find(string)Finds an element or a boundary by identifier.

AddBoundary(string, DiagramText, C4BoundaryKind)

C4Diagram.cs

Adds a top-level boundary.

public C4Boundary AddBoundary(string id, DiagramText label, C4BoundaryKind kind = C4BoundaryKind.Boundary)

Parameters

id string
The identifier (Mermaid alias).
label DiagramText
The name.
kind C4BoundaryKind
The kind.

Returns

C4Boundary The boundary.

AddElement(string, C4ElementKind, DiagramText, DiagramText?)

C4Diagram.cs

Adds an element that is in no boundary.

public C4Element AddElement(string id, C4ElementKind kind, DiagramText label, DiagramText? description = null)

Parameters

id string
The identifier (Mermaid alias).
kind C4ElementKind
The kind.
label DiagramText
The name.
description DiagramText?
The description, or null for none.

Returns

C4Element The element.

AddRelationship(C4Item, C4Item, DiagramText, string?)

C4Diagram.cs

Adds a relationship.

public C4Relationship AddRelationship(C4Item from, C4Item to, DiagramText label, string? technology = null)

Parameters

from C4Item
The source.
to C4Item
The target.
label DiagramText
The text.
technology string?
The technology, shown between brackets below the text, or null for none.

Returns

C4Relationship The relationship.

EnumerateBoundaries()

C4Diagram.cs

Enumerates the boundaries and their nested boundaries, depth first.

public IEnumerable<C4Boundary> EnumerateBoundaries()

Returns

IEnumerable<C4Boundary> The boundaries.

Find(string)

C4Diagram.cs

Finds an element or a boundary by identifier.

public C4Item? Find(string id)

Parameters

id string
The identifier.

Returns

C4Item? The item, or null when there is none.