Trabajar con Métodos [Guía de Usuario de Enterprise Architect]

Top Previous Next

Trabajar con Métodos

button_main button_prev button_next

Temas

Tema

Detalle

public Object

 

''Un ejemplo de trabajar con la colección de Métodos.

''de un elemento - y con colecciones de Métodos.

 

Sub MethodLifeCycle

 

Dim element as object

Dim method as object

Dim t as object

Dim idx as Integer

Dim idx2 as integer

 

try

element = m_Repository.GetElementByID(129)

 

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

method = element.Methods.GetAt(idx)

Console.WriteLine(method.Name)

 

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

If t.Update = false Then

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

End if

 

method.PreConditions.Refresh

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

t = method.PreConditions.GetAt(idx2)

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

If t.Name = "TestConstraint" Then

method.PreConditions.DeleteAt(idx2,false)

End If

Next

 

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

If t.Update = false Then

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

End if

 

method.PostConditions.Refresh

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

Next

 

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

method.TaggedValues.DeleteAt(idx2,false)

End If

Next

 

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

If t.Update = false Then

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

End if

 

method.Parameters.Refresh

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

Next

 

method = nothing

Next

catch e as exception

Console.WriteLine(element.Methods.GetLastError())

Console.WriteLine(e)

End try

 

End Sub