Get Lifelines
Get Lifelines from a Sequence Diagram
To get lifelines, use the Lifelines
property of the ISequenceDiagram
object.
public void GetLifelines(ICommandContext c, ICommandParams p)
{
ISequenceDiagram sequenceDiagram = c.App.Workspace.CurrentEditor as ISequenceDiagram;
if (sequenceDiagram == null) return;
//Get lifelines
ILifelineShapeCollection lifelines = sequenceDiagram.Lifelines;
var no = 1;
foreach (ILifelineShape lifeline in lifelines)
{
c.App.Output.WriteLine("sample", $"{no}th lifeline : {lifeline.Text}");
no++;
}
}
Get lifeline model information from sequence diagram
To get lifeline model information from sequence diagram, first get the interaction model from the Model
property of the ISequenceDiagram
object. After casting the obtained model to IInteraction
type, use the Lifelines
property to obtain the lifeline model information.
public void GetLifelineModels(ICommandContext c, ICommandParams p)
{
ISequenceDiagram sequenceDiagram = c.App.Workspace.CurrentEditor as ISequenceDiagram;
if (sequenceDiagram == null) return;
//Get the interaction model
IInteraction interaction = sequenceDiagram.Model as IInteraction;
//Get the lifeline model
ILifelineCollection lifelineModels = interaction.Lifelines;
var no = 1;
foreach (ILifeline lifelineModel in lifelineModels)
{
c.App.Output.WriteLine("sample", $"{no}th lifeline model : {lifelineModel.Name}");
no++;
}
}