-
Notifications
You must be signed in to change notification settings - Fork 4
Sequence diagram
Aleksey edited this page May 27, 2022
·
3 revisions
Original mermaid-js sequence diagram documentation
A Sequence diagram is an interaction diagram that shows how processes operate with one another and in what order
To create sequence diagram call create new SequenceDiagramBuilder
. You could enable autonumber
of sequence steps within its constructor
var builder = new SequenceDiagramBuilder(autoNumber:true);
var alice = diagram.AddMember("Alice", MemberType.Participant);
var bob = diagram.AddMember("Alice", MemberType.Participant);
You could add links for diagram members
alice.AddLink("Dashboard", new Uri("https://dashboard.contoso.com/alice"));
alice.AddLink("Wiki", new Uri("https://wiki.contoso.com/alice"));
To sent message from one member to another/self
builder
.Message(alice, bob, "Hello Bob!", MessageType.Solid)
.Message(alice, bob, "Hello! Can you hear me?", MessageType.Solid)
For simpler messaging process definition between two members you could use Messaging
builder
.Messaging(alice, bob)
.Request("Hi Bob!", MessageType.SolidArrow)
.Response("Hello Alice!", MessageType.SolidArrow)
.Request("How are you?", MessageType.SolidArrow)
.Response("Well ..", MessageType.DottedArrow)
.Response("Done", MessageType.SolidArrow)
.End()
To do things, when some of the members activated use Activate
method
builder.Activate(alice, diagram =>
{
diagram.Message(alice, bob, "Hello", MessageType.Solid);
});
builder.Loop("Endless conversation", diagram =>
{
diagram.Message(alice, bob, "Hello", MessageType.Solid);
...
});
It is possible to express alternative paths in a sequence diagram
builder.AltOr(
"Alice hungry",
diagram => diagram.Message(alice, bob, "Wait Bob, I need something to eat", MessageType.Solid),
"Alice not hungry",
diagram => diagram.Message(alice, bob, "Ok, let`s go", MessageType.Solid)
);
builder.Optional("Alice tired", diagram => ...);
builder.Parallel(new [] {
("alice is going to work", diagram => ...),
("alice is talking to the phone", diagram => ...)
});
or
builder.Parallel(
("alice is going to work", diagram => ...),
("alice is talking to the phone", diagram => ...)
);
It is possible to highlight flows by providing colored background rects.
builder.Rect(Color.Yellow, diagram => ...);
builder
.Note(alice, NoteLocation.LeftOf, "Alice is a girl")
.Note(bob, NoteLocation.LeftOf, "Bob is a boy");
builder.NoteOver("Teenagers", alice, bob);
string markdownSyntax = builder.Build();