Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Work With Methods




public Object


''An example of working with the Methods collection

''of an element - and with Method collections.


Sub MethodLifeCycle


   Dim element as object

   Dim method as object

   Dim t as object

   Dim idx as Integer

   Dim idx2 as integer



       element = m_Repository.GetElementByID(129)


       For idx = 0 to element.Methods.Count -1

           method = element.Methods.GetAt(idx)



           t = method.PreConditions.AddNew("TestConstraint","something")

           If t.Update = false Then

               Console.WriteLine("PreConditions: " + t.GetLastError)

           End if



           For idx2 = 0 to method.PreConditions.Count-1

               t = method.PreConditions.GetAt(idx2)

               Console.WriteLine("PreConditions: " + t.Name)

               If t.Name = "TestConstraint" Then


               End If



           t = method.PostConditions.AddNew("TestConstraint","something")

           If t.Update = false Then

               COnsole.WriteLine("PostConditions: " + t.GetLastError)

           End if



           For idx2 = 0 to method.PostConditions.Count-1

               t = method.PostConditions.GetAt(idx2)

               Console.WriteLine("PostConditions: " + t.Name)

               If t.Name = "TestConstraint" Then

                   method.PostConditions.DeleteAt(idx2, false)

               End If



           t = method.TaggedValues.AddNew("TestTaggedValue","something")

           If t.Update = false Then

               COnsole.WriteLine("Tagged Values: " + t.GetLastError)

           End if


           For idx2 = 0 to method.TaggedValues.Count-1

               t = method.TaggedValues.GetAt(idx2)

               Console.WriteLine("Tagged Value: " + t.Name)

               If(t.Name= "TestTaggedValue") Then


               End If



           t = method.Parameters.AddNew("TestParam","string")

           If t.Update = false Then

               Console.WriteLine("Parameters: " + t.GetLastError)

           End if



           For idx2 = 0 to method.Parameters.Count-1

               t = method.Parameters.GetAt(idx2)

               Console.WriteLine("Parameter: " + t.Name)

               If(t.Name="TestParam") Then

                   method.Parameters.DeleteAt(idx2, false)

               End If



           method = nothing


   catch e as exception



   End try


End Sub