Description
Returns the value of the attribute attributeName of the object obj, and also sets the variable found to True if the attribute was read correctly.
It's an auxiliary function, called by all the functions listed under Called from paragraph.
Syntax
dim value = GetAttributeBase(obj, attributeName, found) |
obj
the object, to read the attribute attributeName from
attributeName
the name of the attribute to be read from the object obj.
found
variable, returned by reference, with the value=True if the read was successful, or False if it failed.
''' <summary>Read the attribute value as Object</summary> ''' <param name="obj">The object to read</param> ''' <param name="attributeName">The name of the attribute to read</param> ''' <param name="found">True if the attribute's value has been read successfully</param> ''' <returns>The attribute's value as Object</returns> Public Function GetAttributeBase(ByVal obj As IGenericAttrObj, ByVal attributeName As String, ByRef found As Boolean) As Object found = False If Not obj Is Nothing Then Dim at As Schema.AttributeType.Base at = obj.GetAttributeType(attributeName) If Not at Is Nothing Then Dim av As AttributeValue av = obj.GetAttributeValue(at) If av Is Nothing Then 'the attribute value has not been loaded yet obj.LoadAttributes(False) av = obj.GetAttributeValue(at) End If If Not av Is Nothing Then found = True 'if it is an enum attribute then return the string value, not the index If TypeOf at Is Schema.AttributeType.Enum Then If av.Value < 0 Then Return "" Else Return DirectCast(at, Schema.AttributeType.Enum).Values(av.Value) End If Else Return av.Value End If End If Else 'the attribute does not exists into the objectType AttrException(obj, attributeName) End If End If Return Nothing End Function |
<Extension()> _ Public Function GetInteger(ByVal obj As IGenericAttrObj, ByVal attributeName As String) As Integer Dim value As Object Dim found As Boolean value = GetAttributeBase(obj, attributeName, found) If found Then Return CType(value, Integer) End If Return Nothing End Function |