Please note : This help page is for an older version of Enteprise Archtiect. The latest help can be found here.

Work With Attributes

Topics

Topic

Detail

public Object

 

''An example of working with attributes.

 

Sub AttributeLifecycle

 

   Dim element as object

   Dim o 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.Attributes.Count -1

 

           Console.WriteLine("attribute=" + element.Attributes.GetAt(idx).Name)

 

           o = element.Attributes.GetAt(idx)

           t = o.Constraints.AddNew("> 123","Precision")

           t.Update()

           o.Constraints.Refresh

           For idx2 = 0 to o.Constraints.Count-1

               t = o.Constraints.GetAt(idx2)

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

               If(t.Name="> 123") Then

                   o.Constraints.DeleteAt(idx2, false)

               End if

           Next

 

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

               t = o.TaggedValues.GetAt(idx2)

               If(t.Name = "Type2") Then

                   'Console.WriteLine("deleteing")

                   o.TaggedValues.DeleteAt(idx2, true)

               End if

           Next

 

           t = o.TaggedValues.AddNew("Type2","Number")

           t.Update

           o.TaggedValues.Refresh

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

               t = o.TaggedValues.GetAt(idx2)

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

           Next

 

           If(element.Attributes.GetAt(idx).Name = "m_Tootle") Then

               Console.WriteLine("delete attribute")

               element.Attributes.DeleteAt(idx, false)

           End If

 

 

       Next

 

 

   catch e as exception

       Console.WriteLine(element.Attributes.GetLastError())

       Console.WriteLine(e)

   End try

End Sub