Hello,
I have created a collection that has an underlying Array for serialization to xml. The only problem I'm having with it is the 'add' method. When I add a new object is sets all the objects in the collection (and array) to the new item and I don't know why. Here is the class:
Anybody notice what is wrong here?
I have created a collection that has an underlying Array for serialization to xml. The only problem I'm having with it is the 'add' method. When I add a new object is sets all the objects in the collection (and array) to the new item and I don't know why. Here is the class:
VB.NET:
<ComClass()> _
Public Class SerActCollection
Implements ICollection
Public collectionName As String
Private AArray As ArrayList = New ArrayList()
Public Sub New()
End Sub
Default Public Overloads ReadOnly _
Property item(ByVal index As Integer) As SchemaClasses.Activity
Get
Return CType(AArray(index), SchemaClasses.Activity)
End Get
End Property
Public Sub copyTo(ByVal a As Array, ByVal index As Integer) _
Implements ICollection.CopyTo
AArray.CopyTo(a, index)
End Sub
Public ReadOnly Property count() As Integer Implements _
ICollection.Count
Get
count = AArray.Count
End Get
End Property
Public ReadOnly Property syncRoot() As Object _
Implements ICollection.SyncRoot
Get
Return Me
End Get
End Property
Public ReadOnly Property isSynchronized() As Boolean _
Implements ICollection.IsSynchronized
Get
Return False
End Get
End Property
Public Function GetEnumerator() As IEnumerator _
Implements IEnumerable.GetEnumerator
Return AArray.GetEnumerator()
End Function
Public Function Add(ByVal newActivity As SchemaClasses.Activity) As Integer
AArray.Add(newActivity)
Return AArray.Count
End Function
End Class
Anybody notice what is wrong here?
Last edited by a moderator: