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