Imports System.Collections.Generic

Namespace Telerik.GridExamplesVBNET.Programming.CustomPaging
    Public Class MyBusinessObjectCollection
        Private Const _maxItems As Integer = 100000

        Public Sub New()
        End Sub

        Public Function SelectCount() As Integer
            Return _maxItems
        End Function

        Public Function [Select]() As List(Of MyBusinessObject)
            Return [Select](0, _maxItems)
        End Function

        Public Function [Select](ByVal startRowIndex As Integer, ByVal maximumRows As Integer) As List(Of MyBusinessObject)
            Dim list As New List(Of MyBusinessObject)()
            Dim i As Integer = startRowIndex
            While i < Math.Min(_maxItems, startRowIndex + maximumRows)
                If i < 10 Then
                    list.Add(New MyBusinessObject("Number10", 10, Guid.NewGuid(), DateTime.Now, New Random().NextDouble()))
                ElseIf i < 20 Then
                    list.Add(New MyBusinessObject("Number20", 20, Guid.NewGuid(), DateTime.Now, New Random().NextDouble()))
                Else
                    list.Add(New MyBusinessObject("Number" + i.ToString(), i, Guid.NewGuid(), DateTime.Now, New Random().NextDouble()))
                End If
                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While
            Return list
        End Function
    End Class


    Public Class MyBusinessObject
        Private _myProperty1 As String
        Private _myProperty2 As Integer
        Private _myProperty3 As Guid
        Private _myProperty4 As DateTime
        Private _myProperty5 As Double

        Public Sub New(ByVal _myProperty1 As String, ByVal _myProperty2 As Integer, ByVal _myProperty3 As Guid, ByVal _myProperty4 As DateTime, ByVal _myProperty5 As Double)
            Me._myProperty1 = _myProperty1
            Me._myProperty2 = _myProperty2
            Me._myProperty3 = _myProperty3
            Me._myProperty4 = _myProperty4
            Me._myProperty5 = _myProperty5
        End Sub

        Public Property MyProperty1() As String
            Get
                Return _myProperty1
            End Get
            Set(ByVal value As String)
                _myProperty1 = value
            End Set
        End Property

        Public Property MyProperty2() As Integer
            Get
                Return _myProperty2
            End Get
            Set(ByVal value As Integer)
                _myProperty2 = value
            End Set
        End Property

        Public Property MyProperty3() As Guid
            Get
                Return _myProperty3
            End Get
            Set(ByVal value As Guid)
                _myProperty3 = value
            End Set
        End Property

        Public Property MyProperty4() As DateTime
            Get
                Return _myProperty4
            End Get
            Set(ByVal value As DateTime)
                _myProperty4 = value
            End Set
        End Property

        Public Property MyProperty5() As Double
            Get
                Return _myProperty5
            End Get
            Set(ByVal value As Double)
                _myProperty5 = value
            End Set
        End Property

    End Class

End Namespace

