Public Class Customer
Private _id, _countryId As Integer
Private _name, _email, _city As String
Private _OrderDate As DateTime
Private _orderTotal As Double
Shared _rnd As Random = New Random()
Shared _firstNames As String() = "Andy|Ben|Charlie|Dan|Ed|Fred|Herb|Jack|Mark|Ted".Split("|"c)
Shared _lastNames As String() = "Ambers|Bishop|Cole|Danson|Evers|Frommer|Heath|Myers|Richards|Stevens".Split("|"c)
Shared _emailServers As String() = "gmail|yahoo|outlook|aol".Split("|"c)
Shared countries As String = "China-Beijing,Shanghai|India-Delhi,Kolkata|United States-Washington,New York|Russia-Moscow,Saint Petersburg|Japan-Tokio,Yokohama"
Shared _countries As KeyValuePair(Of String, String())() = countries.Split("|"c).[Select](Function(str) New KeyValuePair(Of String, String())(str.Split("-"c).First(), str.Split("-"c).Skip(1).First().Split(","c))).ToArray()
Public Sub New()
End Sub
Public Sub New(ByVal id As Integer)
id = id
Name = GetName()
Email = String.Format("{0}@{1}.com", (Name.Substring(0, 3)).ToLower(), GetString(_emailServers))
CountryId = _rnd.[Next]() Mod _countries.Length
Dim cities = _countries(CountryId).Value
City = GetString(cities)
OrderDate = DateTime.Today.AddDays(-_rnd.[Next](1, 365)).AddHours(_rnd.[Next](0, 24)).AddMinutes(_rnd.[Next](0, 60))
OrderTotal = Math.Round(_rnd.NextDouble() * 10000.0, 2)
End Sub
Public Property ID As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
If value <> _id Then
_id = value
End If
End Set
End Property
Public Property Name As String
Get
Return _name
End Get
Set(ByVal value As String)
If value <> _name Then
_name = value
End If
End Set
End Property
Public Property Email As String
Get
Return _email
End Get
Set(ByVal value As String)
If value <> _email Then
_email = value
End If
End Set
End Property
Public Property City As String
Get
Return _city
End Get
Set(ByVal value As String)
If value <> _city Then
_city = value
End If
End Set
End Property
Public Property CountryId As Integer
Get
Return _countryId
End Get
Set(ByVal value As Integer)
If value <> _countryId AndAlso value > -1 AndAlso value < _countries.Length Then
_countryId = value
End If
End Set
End Property
Public Property OrderDate As DateTime
Get
Return _OrderDate
End Get
Set(ByVal value As DateTime)
If value <> _OrderDate Then
_OrderDate = value
End If
End Set
End Property
Public Property OrderTotal As Double
Get
Return _orderTotal
End Get
Set(ByVal value As Double)
If value <> _orderTotal Then
_orderTotal = value
End If
End Set
End Property
Private Shared Function GetString(ByVal arr As String()) As String
Return arr(_rnd.[Next](arr.Length))
End Function
Private Shared Function GetName() As String
Return String.Format("{0} {1}", GetString(_firstNames), GetString(_lastNames))
End Function
Public ReadOnly Property Country As String
Get
Return _countries(_countryId).Key
End Get
End Property
Public Shared Function GetCustomerList(ByVal count As Integer) As ObservableCollection(Of Customer)
Dim list = New ObservableCollection(Of Customer)()
For i As Integer = 0 To count - 1
list.Add(New Customer(i))
Next
Return list
End Function
End Class