Skip to content

Commit

Permalink
Adding EnterpriseDiagramBuilder.cs Structure into sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
yanjustino committed Nov 17, 2021
1 parent 10fd512 commit c8295f9
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static string ToPumlString(this EnterpriseBoundary boundary)

foreach (var structure in boundary.Structures)
{
if (structure is (Person or SoftwareSystem))
if (structure is (Person or SoftwareSystem or EnterpriseBoundary))
{
stream.AppendLine($"{SpaceMethods.Indent()}{structure.ToPumlString()}");
}
Expand Down
58 changes: 58 additions & 0 deletions src/samples/C4Sharp.Sample/Diagrams/EnterpriseDiagramBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using C4Sharp.Diagrams.Core;
using C4Sharp.Models;
using C4Sharp.Models.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
{
using static Position;
using static People;
using static Systems;

public class EnterpriseDiagramBuilder
{
public static ContextDiagram Build()
{
return new ()
{
Title = "System Enterprise diagram for Internet Banking System",
Structures = new Structure[]
{
Customer,
new EnterpriseBoundary("eboundary", "Domain A")
{
Structures = new Structure []
{
BankingSystem,
new EnterpriseBoundary("eboundary1", "Domain Internal Users")
{
Structures = new Structure []
{
InternalCustomer,
}
},
new EnterpriseBoundary("eboundary2", "Domain Managers")
{
Structures = new Structure []
{
Manager,
}
},
}
},
Mainframe,
MailSystem
},
Relationships = new[]
{
Customer > BankingSystem,
InternalCustomer > BankingSystem,
Manager > BankingSystem,
(Customer < MailSystem)["Sends e-mails to"],
(BankingSystem > MailSystem)["Sends e-mails", "SMTP"][Neighbor],
BankingSystem > Mainframe,
}
};
}
}
}
5 changes: 4 additions & 1 deletion src/samples/C4Sharp.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Plantuml;
using C4Sharp.Sample.Diagrams;

Expand All @@ -13,11 +14,13 @@ private static void Main(string[] args)
ContextDiagramBuilder.Build(),
ContainerDiagramBuilder.Build(),
ComponentDiagramBuilder.Build(),
DeploymentDiagramBuilder.Build()
DeploymentDiagramBuilder.Build(),
EnterpriseDiagramBuilder.Build(),
};

new PlantumlSession()
.UseDiagramImageBuilder()
.UseDiagramSvgImageBuilder()
.UseStandardLibraryBaseUrl()
.Export(diagrams);
}
Expand Down
16 changes: 15 additions & 1 deletion src/samples/C4Sharp.Sample/Structures/People.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using C4Sharp.Models;
using C4Sharp.Models.Relationships;

namespace C4Sharp.Sample.Structures
{
Expand All @@ -8,7 +9,20 @@ public static class People

public static Person Customer => _customer ??= new Person("customer", "Personal Banking Customer")
{
Description = "A customer of the bank, with personal bank accounts."
Description = "A customer of the bank, with personal bank accounts.",
Boundary = Boundary.External
};

private static Person _internalCustomer;
public static Person InternalCustomer => _internalCustomer ??= new Person("internalcustomer", "Personal Banking Customer")
{
Description = "An internal customer of the bank, with personal bank accounts."
};

private static Person _manager;
public static Person Manager => _manager ??= new Person("manager", "Manager Banking Customer")
{
Description = "A manager of the bank, with personal bank accounts."
};
}
}

0 comments on commit c8295f9

Please sign in to comment.