# Native actor and use case captions · Topology

Preview

![Native actor and use case captions](usecase-source-depth-compact-light.png)

![Native actor and use case captions](usecase-source-depth-compact-dark.png)

390 × 620 pixels

## Create this example

Create a console project, add the ChartForgeX package, and replace Program.cs with this source. Run it to write SVG, PNG and HTML with the default system fonts.

For the same typography as the gallery, [download the gallery-font recipe](usecase-source-depth-compact-light.gallery.csharp.txt) and copy the gallery’s fonts directory beside your program.

```
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = ThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = UseCaseSourceDepthRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 620)), theme, mode,
    new VisualFrame("Native actor and use case captions", "Native stereotypes, attached approval notes and independently styled named associations", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Topology).ToHtmlPage());
#endregion

/// <summary>Authors native actors, use cases, visible stereotypes, notes and independently styled associations.</summary>
/// <remarks>The separately shared Mermaid fixture proves source parsing; this Core recipe uses only native public APIs.</remarks>
public static class UseCaseSourceDepthRecipe {
    /// <summary>Creates the complete native example in wide/compact and light/dark variants.</summary>
    public static TopologyChart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var chart = TopologyChart.Create().Id("native-usecase-depth").Title("Publish prepared documents")
            .Subtitle("Actors, stereotypes, approval notes and named associations")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Viewport(new TopologyViewport(compact ? 390 : 900, compact ? 620 : 520, 28))
            .LayoutMode(TopologyLayoutMode.Swimlane).LayoutDirection(compact ? TopologyLayoutDirection.TopToBottom : TopologyLayoutDirection.LeftToRight);
        chart.DefaultRenderOptions = new TopologyRenderOptions { FitContentToViewport = true,
            MaxNodeLabelLines = 8, MaxNodeSubtitleLines = 8, WrapNodeLabels = true, AllowMultilineNodeLabels = true };
        chart.AddAutoGroup("Service", "Publication service");
        chart.AddAutoNode("Operator", "Release coordinator", width: 190, height: 110);
        chart.AddAutoNode("Publish", "Publish prepared documents", groupId: "Service", width: 200, height: 92);
        chart.AddAutoNode("Validate", "Validate request", groupId: "Service", width: 180, height: 76);
        foreach (var node in chart.Nodes) {
            node.Kind = TopologyNodeKind.Generic; node.Shape = node.Id == "Operator" ? TopologyNodeShape.Actor : TopologyNodeShape.Ellipse;
            node.DisplayMode = TopologyNodeDisplayMode.Card; node.PreserveDisplayModeSize = true; node.ShowStatusBadge = false;
            node.FitLabelToContent = node.Shape != TopologyNodeShape.Actor; node.MaximumTextWidth = 150;
            if (node.Shape != TopologyNodeShape.Actor) node.TextStyle = new ChartForgeX.Typography.TextStyleOverride { FontSize = 13, FontWeight = 400 };
        }
        chart.Nodes[0].Subtitle = "«primary»";
        chart.Nodes[0].TextStyle = new ChartForgeX.Typography.TextStyleOverride { FontSize = 14, FontWeight = 500 };
        chart.Nodes[1].Subtitle = "«business action»";
        chart.AddEdge("request", "Operator", "Publish", "requests", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        var request = chart.Edges[0]; request.Color = ChartColor.FromHex("#2563EB"); request.LabelColor = ChartColor.FromHex("#0F766E");
        request.StrokeWidth = 2.5; request.Opacity = .8; request.LineStyle = TopologyEdgeLineStyle.Solid;
        request.DashPattern.AddRange(new[] { 6d, 3, 2, 6, 3, 2 });
        chart.AddEdge("include-validation", "Publish", "Validate", "<<include>>", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.Edges[1].LineStyle = TopologyEdgeLineStyle.Dotted; chart.Edges[1].MinimumRankSpan = 2;
        chart.Annotations.Add(new TopologyAnnotation("approval", "Approval required before delivery", "Publish"));
        chart.Accessibility.Name = "Document publication use cases";
        return chart;
    }
}
```

```
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = ThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = UseCaseSourceDepthRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 620)), theme, mode,
    new VisualFrame("Native actor and use case captions", "Native stereotypes, attached approval notes and independently styled named associations", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Topology).ToHtmlPage());
#endregion

/// <summary>Authors native actors, use cases, visible stereotypes, notes and independently styled associations.</summary>
/// <remarks>The separately shared Mermaid fixture proves source parsing; this Core recipe uses only native public APIs.</remarks>
public static class UseCaseSourceDepthRecipe {
    /// <summary>Creates the complete native example in wide/compact and light/dark variants.</summary>
    public static TopologyChart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var chart = TopologyChart.Create().Id("native-usecase-depth").Title("Publish prepared documents")
            .Subtitle("Actors, stereotypes, approval notes and named associations")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Viewport(new TopologyViewport(compact ? 390 : 900, compact ? 620 : 520, 28))
            .LayoutMode(TopologyLayoutMode.Swimlane).LayoutDirection(compact ? TopologyLayoutDirection.TopToBottom : TopologyLayoutDirection.LeftToRight);
        chart.DefaultRenderOptions = new TopologyRenderOptions { FitContentToViewport = true,
            MaxNodeLabelLines = 8, MaxNodeSubtitleLines = 8, WrapNodeLabels = true, AllowMultilineNodeLabels = true };
        chart.AddAutoGroup("Service", "Publication service");
        chart.AddAutoNode("Operator", "Release coordinator", width: 190, height: 110);
        chart.AddAutoNode("Publish", "Publish prepared documents", groupId: "Service", width: 200, height: 92);
        chart.AddAutoNode("Validate", "Validate request", groupId: "Service", width: 180, height: 76);
        foreach (var node in chart.Nodes) {
            node.Kind = TopologyNodeKind.Generic; node.Shape = node.Id == "Operator" ? TopologyNodeShape.Actor : TopologyNodeShape.Ellipse;
            node.DisplayMode = TopologyNodeDisplayMode.Card; node.PreserveDisplayModeSize = true; node.ShowStatusBadge = false;
            node.FitLabelToContent = node.Shape != TopologyNodeShape.Actor; node.MaximumTextWidth = 150;
            if (node.Shape != TopologyNodeShape.Actor) node.TextStyle = new ChartForgeX.Typography.TextStyleOverride { FontSize = 13, FontWeight = 400 };
        }
        chart.Nodes[0].Subtitle = "«primary»";
        chart.Nodes[0].TextStyle = new ChartForgeX.Typography.TextStyleOverride { FontSize = 14, FontWeight = 500 };
        chart.Nodes[1].Subtitle = "«business action»";
        chart.AddEdge("request", "Operator", "Publish", "requests", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        var request = chart.Edges[0]; request.Color = ChartColor.FromHex("#2563EB"); request.LabelColor = ChartColor.FromHex("#0F766E");
        request.StrokeWidth = 2.5; request.Opacity = .8; request.LineStyle = TopologyEdgeLineStyle.Solid;
        request.DashPattern.AddRange(new[] { 6d, 3, 2, 6, 3, 2 });
        chart.AddEdge("include-validation", "Publish", "Validate", "<<include>>", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.Edges[1].LineStyle = TopologyEdgeLineStyle.Dotted; chart.Edges[1].MinimumRankSpan = 2;
        chart.Annotations.Add(new TopologyAnnotation("approval", "Approval required before delivery", "Publish"));
        chart.Accessibility.Name = "Document publication use cases";
        return chart;
    }
}
```

<!-- PowerForge markdown artifact sha256:9564EAFF0BC60500B2775865E80277F7E6899C44C2DDF26A2C94232184EB13B3 -->
