From d74edbb6169472872dda98c9d375782d37bd2bb3 Mon Sep 17 00:00:00 2001 From: yanjustino Date: Wed, 17 Nov 2021 19:40:45 -0300 Subject: [PATCH] Adding EnterpriseBoundary.cs Diagram --- .../C4Sharp/Models/EnterpriseBoundary.cs | 10 +++++++++ .../Models/Plantuml/PlantumlStructure.cs | 22 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/components/C4Sharp/Models/EnterpriseBoundary.cs diff --git a/src/components/C4Sharp/Models/EnterpriseBoundary.cs b/src/components/C4Sharp/Models/EnterpriseBoundary.cs new file mode 100644 index 0000000..8e120df --- /dev/null +++ b/src/components/C4Sharp/Models/EnterpriseBoundary.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; + +namespace C4Sharp.Models +{ + public record EnterpriseBoundary(string Alias, string Label) : Structure(Alias, Label) + { + public IEnumerable Structures { get; init; } = Array.Empty(); + } +} \ No newline at end of file diff --git a/src/components/C4Sharp/Models/Plantuml/PlantumlStructure.cs b/src/components/C4Sharp/Models/Plantuml/PlantumlStructure.cs index fbb56e6..69fc488 100644 --- a/src/components/C4Sharp/Models/Plantuml/PlantumlStructure.cs +++ b/src/components/C4Sharp/Models/Plantuml/PlantumlStructure.cs @@ -24,6 +24,7 @@ public static string ToPumlString(this Structure structure) Component component => component.ToPumlString(), Container container => container.ToPumlString(), ContainerBoundary containerBoundary => containerBoundary.ToPumlString(), + EnterpriseBoundary enterpriseBoundary => enterpriseBoundary.ToPumlString(), _ => string.Empty }; } @@ -56,7 +57,26 @@ private static string ToPumlString(this SoftwareSystemBoundary boundary) stream.AppendLine("}"); return stream.ToString(); - } + } + + private static string ToPumlString(this EnterpriseBoundary boundary) + { + var stream = new StringBuilder(); + stream.AppendLine(); + stream.AppendLine($"Enterprise_Boundary({boundary.Alias}, \"{boundary.Label}\") {{"); + + foreach (var structure in boundary.Structures) + { + if (structure is (Person or SoftwareSystem)) + { + stream.AppendLine($"{SpaceMethods.Indent()}{structure.ToPumlString()}"); + } + } + + stream.AppendLine("}"); + + return stream.ToString(); + } private static string ToPumlString(this Component component) {