Option Strict On
Option Explicit On

Imports System.Collections.Generic
Imports System.Collections.ObjectModel

Namespace Nexamas.UI.DataBinding

    Friend NotInheritable Class MASItemsSourceSnapshot

        Private ReadOnly _items As IReadOnlyList(Of MASItemsSourceItem)

        Friend Sub New(items As IEnumerable(Of MASItemsSourceItem),
                       revision As Integer)
            Dim normalized As New List(Of MASItemsSourceItem)()
            If items IsNot Nothing Then
                For Each item As MASItemsSourceItem In items
                    If item IsNot Nothing Then normalized.Add(item)
                Next
            End If
            _items = New ReadOnlyCollection(Of MASItemsSourceItem)(normalized.ToArray())
            Me.Revision = revision
        End Sub

        Friend ReadOnly Property Revision As Integer

        Friend ReadOnly Property Count As Integer
            Get
                Return _items.Count
            End Get
        End Property

        Friend ReadOnly Property Items As IReadOnlyList(Of MASItemsSourceItem)
            Get
                Return _items
            End Get
        End Property

    End Class

End Namespace
