Release 4.1.x
C4Sharp version 4.1.x is released 🚀
We released a new version of C4Sharp. The release includes new improvements such as minor bug fixes to the write test log, code maintainability, and performance. You can read the full list of new enhancements and bug fixes below:
- Update resource files
- Remove unnecessary namespaces
- Using instance name for container
- Enabling Diagrams to use tags and styles elements.
- ElementStyle
- ElementTag
- RelTab
Improvements 😎
Using instance name for container
Now, is possible create new container instances by name:
Containers.OracleDatabase[1];
Containers.OracleDatabase["Data Reader"];
see how to create new container instances by name in this sample code.
Custom tags/stereotypes support and skinparam updates
Now, C4Sharp provides new structures to customize diagram elements using C4-Plantuml methods such as:
-
AddElementTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape)
: Introduces a new element tag. The styles of the tagged elements are updated and the tag is displayed in the calculated legend. -
AddRelTag(tagStereo, ?textColor, ?lineColor, ?lineStyle)
: Introduces a new relation tag. The styles of the tagged relations are updated and the tag is displayed in the calculated legend. -
UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape)
: This call updates the default style of the elements (component, ...) and creates no additional legend entry.
Using customization elements
see in the following code how to use customization structures:
internal static class Program
{
// Elements customization
private static readonly ElementStyle Style = new ElementStyle()
.UpdateElementStyle(ElementName.ExternalPerson, "#7f3b08", "#7f3b08")
.UpdateElementStyle(ElementName.Person, "#55ACEE", "#55ACEE")
.UpdateElementStyle(ElementName.ExternalSystem, "#3F6684", shape: Shape.RoundedBoxShape);
// Relationship customization
private static readonly RelationshipTag Reltags = new RelationshipTag()
.AddRelTag("error", "red", "red", LineStyle.DashedLine);
// Tagged elements customization
private static readonly ElementTag Tags = new ElementTag()
.AddElementTag("services", "#3F6684", shape: Shape.EightSidedShape);
private static void Main()
{
var diagrams = new []
{
ContextDiagramBuilder.Build().SetStyle(Style).SetRelTags(Reltags), //update element style
ContainerDiagramBuilder.Build().SetTags(Tags), //set tagged elements customization
ComponentDiagramBuilder.Build(),
DeploymentDiagramBuilder.Build(),
EnterpriseDiagramBuilder.Build().SetStyle(Style), // update element style
};
new PlantumlSession()
.UseDiagramImageBuilder()
.UseDiagramSvgImageBuilder()
.UseStandardLibraryBaseUrl()
.Export(diagrams);
}
}
Tagging diagram structures and relationships
see in the following code how to tagging diagram structures and relationships:
// Tagging the structure
public static SoftwareSystem BankingSystem => new SoftwareSystem("BankingSystem", "Internet Banking System")
{
Description = "Allows customers to view information about their bank accounts, and make payments.",
Tags = new []{ "services" }
};
return new ContextDiagram()
{
Title = "System Context diagram for Internet Banking System",
Structures = new Structure[]
{
Customer,
BankingSystem,
Mainframe,
MailSystem
},
Relationships = new[]
{
(Customer > BankingSystem).AddTags("error"), // Tagging the relationships
(Customer < MailSystem)["Sends e-mails to"],
(BankingSystem > MailSystem)["Sends e-mails", "SMTP"][Neighbor],
BankingSystem > Mainframe,
}
};
See more in our sample code