预订演示

请注意 : 本帮助页面不适用于最新版本的Enterprise Architect. 最新的帮助文档在这里.

前页 后页

Add and Manage Packages

This example illustrates how to add a model or a Package to the project.

Sub TestPackageLifecycle
     Dim idx as integer
     Dim idx2 as integer
     Dim package as object
     Dim model as object
     Dim o as object

     ''first add a new Model

     model = m_Repository.Models.AddNew("AdvancedModel","")
     If not model.Update() Then
          Console.WriteLine(model.GetLastError())
     End If

     ''refresh the models collection
     m_Repository.Models.Refresh

     ''now work through models collection and add a Package

     For idx = 0 to m_Repository.Models.Count -1
          o = m_Repository.Models.GetAt(idx)
          Console.WriteLine(o.Name)
          If o.Name = "AdvancedModel" Then
               package = o.Packages.Addnew("Subpackage","Nothing")
               If not package.Update() Then
                    Console.WriteLine(package.GetLastError())
               End If

               package.Element.Stereotype = "system"
               package.Update

               ''for testing purposes just delete the
               ''newly created Model and its contents
               "m_Repository.Models.Delete(idx)

          End If
     Next

End Sub