如何以编程方式编辑序列图 [英] How can i edit Sequence Diagrams programmatically

查看:98
本文介绍了如何以编程方式编辑序列图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试像这样更改现有的SD

I try to change existing SD like this

using (IModelingProjectReader projectReader = ModelingProject.LoadReadOnly(projectPath))
{
                
                var sd = projectReader.LoadDiagram(Filename) as ISequenceDiagram;
		IInteraction interaction = sd.Interaction;
		var newLifeLine = interaction.CreateLifeline();
}

并获取System.InvalidOperationException-无法在锁定的父项,分区或存储中添加新的生命线."

and get System.InvalidOperationException - "Cannot add a new Lifeline within a locked parent, partition or store."

如果我尝试添加或删除一些元素,我会通过活动图得到相同的错误.我做错了什么?

The same error i get by Activity diagrams if i try to add or delete some elements. What i do wrong?

P.S.我知道这篇文章 http://msdn.microsoft.com/zh-CN/library/vstudio/ee349042.aspx ,但是他们是否这样做?

P.S. I know this article http://msdn.microsoft.com/en-US/library/vstudio/ee349042.aspx, but they are doing the same, or not?

推荐答案

问题是您正在使用LoadReadOnly.

The problem is that you are using LoadReadOnly.

相反,您需要以可写状态打开模型.看中的例子 如何打开UML模型.

Instead, you need to open the model in a writable state. Look at the examples in How to Open a UML Model.


这篇关于如何以编程方式编辑序列图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆