PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/SongDatabase/Items/PlayListEnumerator.vb

#
Visual Basic | 62 lines | 22 code | 8 blank | 32 comment | 0 complexity | a7e992c2f04fc379c1734e534a9974d0 MD5 | raw file
 1Namespace Items
 2
 3    ''' <summary>
 4    ''' Allows play list items to be enumerated.
 5    ''' </summary>
 6    Public Class PlayListEnumerator
 7        Implements IEnumerator
 8
 9        Private FPlayList As PlayList = Nothing
10        Private FPosition As Integer = -1
11
12        ''' <summary>
13        ''' Gets the current element in the collection.
14        ''' </summary>
15        ''' <value></value>
16        ''' <returns>
17        ''' The current element in the collection.
18        ''' </returns>
19        ''' <exception cref="T:System.InvalidOperationException">
20        ''' The enumerator is positioned before the first element of the collection or after the last element.
21        ''' </exception>
22        Public ReadOnly Property Current() As Object Implements System.Collections.IEnumerator.Current
23            Get
24                Return FPlayList(FPosition)
25            End Get
26        End Property
27
28        ''' <summary>
29        ''' Advances the enumerator to the next element of the collection.
30        ''' </summary>
31        ''' <returns>
32        ''' true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
33        ''' </returns>
34        ''' <exception cref="T:System.InvalidOperationException">
35        ''' The collection was modified after the enumerator was created.
36        ''' </exception>
37        Public Function MoveNext() As Boolean Implements System.Collections.IEnumerator.MoveNext
38            FPosition += 1
39            Return FPosition < FPlayList.Count
40        End Function
41
42        ''' <summary>
43        ''' Sets the enumerator to its initial position, which is before the first element in the collection.
44        ''' </summary>
45        ''' <exception cref="T:System.InvalidOperationException">
46        ''' The collection was modified after the enumerator was created.
47        ''' </exception>
48        Public Sub Reset() Implements System.Collections.IEnumerator.Reset
49            FPosition = -1
50        End Sub
51
52        ''' <summary>
53        ''' Initializes a new instance of the <see cref="PlayListEnumerator" /> class.
54        ''' </summary>
55        ''' <param name="playList">The play list.</param>
56        Public Sub New(ByVal playList As PlayList)
57            FPlayList = playList
58        End Sub
59
60    End Class
61
62End Namespace