Skip to content

Commit

Permalink
Merge pull request #33 from Robunnin/feature-component-types
Browse files Browse the repository at this point in the history
Added component types
  • Loading branch information
yanjustino authored Jun 30, 2022
2 parents 3036ef6 + 9141edd commit ebbbdc6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/C4Sharp/Models/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,37 @@ public record Component : Structure
{
public string? Technology { get; init; }

public ComponentType ComponentType { get; init; }

public Component(string alias, string label): base(alias, label)
{
ComponentType = ComponentType.None;
}

public Component(StructureIdentity alias, string label): base(alias, label)
{
ComponentType = ComponentType.None;
}

public Component(string alias, string label, string technology): this(alias, label)
{
Technology = technology;
}

public Component(string alias, string label, ComponentType componentType, string technology): this(alias, label, technology)
{
ComponentType = componentType;
}

public Component(string alias, string label, string technology, string description): this(alias, label)
{
Technology = technology;
Description = description;
}

public Component(string alias, string label, ComponentType componentType, string technology, string description): this(alias, label, technology, description)
{
ComponentType = componentType;
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/C4Sharp/Models/ComponentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel;

namespace C4Sharp.Models;

/// <summary>
/// Component types
/// </summary>
public enum ComponentType
{
[Description("Database")]
Database,

[Description("Queue")]
Queue,

[Description("")]
None
}
8 changes: 7 additions & 1 deletion src/C4Sharp/Models/Plantuml/Extensions/PlantumlStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ private static string ToPumlString(this EnterpriseBoundary boundary)

private static string ToPumlString(this Component component)
{
var procedureName = $"Component{GetExternalSuffix(component)}";
var externalSuffix = GetExternalSuffix(component);
var procedureName = component.ComponentType switch
{
ComponentType.Database => $"ComponentDb{externalSuffix}",
ComponentType.Queue => $"ComponentQueue{externalSuffix}",
_ => $"Component{externalSuffix}"
};

return
$"{procedureName}({component.Alias}, \"{component.Label}\", \"{component.Technology}\", \"{component.Description}\""
Expand Down

0 comments on commit ebbbdc6

Please sign in to comment.