-
Notifications
You must be signed in to change notification settings - Fork 38
Getting Started
Yan Justino edited this page Nov 20, 2021
·
12 revisions
C4Sharp
is a .net library for building C4 Diagrams. Learn what C4S is all about on our homepage or in the tutorial.
This package is available through Nuget Packages: https://www.nuget.org/packages/C4Sharp
Package | Version | Downloads |
---|---|---|
C4Sharp |
Nuget
Install-Package C4Sharp
.NET CLI
dotnet add package C4Sharp
You need these things to run C4Sharp:
C4S diagrams have a basic structure containing a Title, a set of C4 structures and their Relationships. As shown in following code:
//Person
public static Person Customer => new Person("customer", "Personal Banking Customer")
{
Description = "..."
};
// Systems
public static SoftwareSystem BankingSystem => new SoftwareSystem("BankingSystem", "Internet Banking System")
{
Description = "..."
};
public static SoftwareSystem Mainframe => new SoftwareSystem("Mainframe", "Mainframe Banking System")
{
Description = "...",
Boundary = Boundary.External
};
public static SoftwareSystem MailSystem => new SoftwareSystem("MailSystem", "E-mail system")
{
Description = "...",
Boundary = Boundary.External
};
var diagram = new ContextDiagram
{
Title = "System Context diagram for Internet Banking System",
Structures = new Structure[]
{
Customer,
BankingSystem,
Mainframe,
MailSystem
},
Relationships = new []
{
(Customer > BankingSystem),
(Customer < MailSystem)["Sends e-mails to"],
(BankingSystem > MailSystem)["Sends e-mails", "SMTP"][Neighbor],
(BankingSystem > Mainframe),
}
};
For saving your diagram:
private static void Main()
{
var diagrams = new Diagram[]
{
new ContextDiagram { ... },
new ContainerDiagram { ... },
new ComponentDiagram { ... },
new DeploymentDiagram { ... },
new EnterpriseDiagram { ... },
};
new PlantumlSession()
.UseDiagramImageBuilder() // To generate PNG Files
.UseDiagramSvgImageBuilder() // To generate SVG Files
.UseStandardLibraryBaseUrl() // To use C4-Planguml Library from their github
.Export(diagrams);
}
the result shoul be:
The resource files are saved separately from your diagram files into .c4s
folder. See more in our sample code