Imports System.IO
Imports System.Reflection
Imports System.Globalization

Public Class Invoice
    Public Property CustomerID() As String
        Get
            Return m_CustomerID
        End Get
        Set(value As String)
            m_CustomerID = value
        End Set
    End Property
    Private m_CustomerID As String
    Public Property CompanyName() As String
        Get
            Return m_CompanyName
        End Get
        Set(value As String)
            m_CompanyName = value
        End Set
    End Property
    Private m_CompanyName As String
    Public Property Address() As String
        Get
            Return m_Address
        End Get
        Set(value As String)
            m_Address = value
        End Set
    End Property
    Private m_Address As String
    Public Property City() As String
        Get
            Return m_City
        End Get
        Set(value As String)
            m_City = value
        End Set
    End Property
    Private m_City As String
    Public Property Region() As String
        Get
            Return m_Region
        End Get
        Set(value As String)
            m_Region = value
        End Set
    End Property
    Private m_Region As String
    Public Property PostalCode() As String
        Get
            Return m_PostalCode
        End Get
        Set(value As String)
            m_PostalCode = value
        End Set
    End Property
    Private m_PostalCode As String
    Public Property Country() As String
        Get
            Return m_Country
        End Get
        Set(value As String)
            m_Country = value
        End Set
    End Property
    Private m_Country As String
    Public Property Salesperson() As String
        Get
            Return m_Salesperson
        End Get
        Set(value As String)
            m_Salesperson = value
        End Set
    End Property
    Private m_Salesperson As String

    Public Property OrderID() As UInteger
        Get
            Return m_OrderID
        End Get
        Set(value As UInteger)
            m_OrderID = value
        End Set
    End Property
    Private m_OrderID As UInteger
    Public Property OrderDate() As DateTime
        Get
            Return m_OrderDate
        End Get
        Set(value As DateTime)
            m_OrderDate = value
        End Set
    End Property
    Private m_OrderDate As DateTime
    Public Property Weekday() As DayOfWeek
        Get
            Return m_Weekday
        End Get
        Set(value As DayOfWeek)
            m_Weekday = value
        End Set
    End Property
    Private m_Weekday As DayOfWeek
    Public Property RequiredDate() As DateTime
        Get
            Return m_RequiredDate
        End Get
        Set(value As DateTime)
            m_RequiredDate = value
        End Set
    End Property
    Private m_RequiredDate As DateTime
    Public Property ShippedDate() As DateTime
        Get
            Return m_ShippedDate
        End Get
        Set(value As DateTime)
            m_ShippedDate = value
        End Set
    End Property
    Private m_ShippedDate As DateTime

    Public Property Shipper() As String
        Get
            Return m_Shipper
        End Get
        Set(value As String)
            m_Shipper = value
        End Set
    End Property
    Private m_Shipper As String
    Public Property ProductID() As UInteger
        Get
            Return m_ProductID
        End Get
        Set(value As UInteger)
            m_ProductID = value
        End Set
    End Property
    Private m_ProductID As UInteger
    Public Property ProductName() As String
        Get
            Return m_ProductName
        End Get
        Set(value As String)
            m_ProductName = value
        End Set
    End Property
    Private m_ProductName As String
    Public Property UnitPrice() As Decimal
        Get
            Return m_UnitPrice
        End Get
        Set(value As Decimal)
            m_UnitPrice = value
        End Set
    End Property
    Private m_UnitPrice As Decimal
    Public Property Quantity() As UInteger
        Get
            Return m_Quantity
        End Get
        Set(value As UInteger)
            m_Quantity = value
        End Set
    End Property
    Private m_Quantity As UInteger
    Public Property Discount() As Decimal
        Get
            Return m_Discount
        End Get
        Set(value As Decimal)
            m_Discount = value
        End Set
    End Property
    Private m_Discount As Decimal
    Public Property ExtendedPrice() As Decimal
        Get
            Return m_ExtendedPrice
        End Get
        Set(value As Decimal)
            m_ExtendedPrice = value
        End Set
    End Property
    Private m_ExtendedPrice As Decimal
    Public Property Freight() As Decimal
        Get
            Return m_Freight
        End Get
        Set(value As Decimal)
            m_Freight = value
        End Set
    End Property
    Private m_Freight As Decimal

    Public Property ShipName() As String
        Get
            Return m_ShipName
        End Get
        Set(value As String)
            m_ShipName = value
        End Set
    End Property
    Private m_ShipName As String
    Public Property ShipAddress() As String
        Get
            Return m_ShipAddress
        End Get
        Set(value As String)
            m_ShipAddress = value
        End Set
    End Property
    Private m_ShipAddress As String
    Public Property ShipCity() As String
        Get
            Return m_ShipCity
        End Get
        Set(value As String)
            m_ShipCity = value
        End Set
    End Property
    Private m_ShipCity As String
    Public Property ShipRegion() As String
        Get
            Return m_ShipRegion
        End Get
        Set(value As String)
            m_ShipRegion = value
        End Set
    End Property
    Private m_ShipRegion As String
    Public Property ShipPostalCode() As String
        Get
            Return m_ShipPostalCode
        End Get
        Set(value As String)
            m_ShipPostalCode = value
        End Set
    End Property
    Private m_ShipPostalCode As String
    Public Property ShipCountry() As String
        Get
            Return m_ShipCountry
        End Get
        Set(value As String)
            m_ShipCountry = value
        End Set
    End Property
    Private m_ShipCountry As String
    Public Property CategoryName() As String
        Get
            Return m_CategoryName
        End Get
        Set(value As String)
            m_CategoryName = value
        End Set
    End Property
    Private m_CategoryName As String

    Public Shared Function GetInvoices() As List(Of Invoice)
        Dim list As New List(Of Invoice)()

        Dim stream As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("_1384442_RadPivotGridCalculatedField.PivotTables10.txt")
        Dim streamReader = New StreamReader(stream)
        Dim file As String = streamReader.ReadToEnd()
        Using reader = New StringReader(file)
            While reader.Peek() <> -1
                Dim items As String() = reader.ReadLine().Split(ControlChars.Tab)
                Dim index As Integer = -1
                Dim invoice_ As New Invoice() With {
                     .CustomerID = items(System.Threading.Interlocked.Increment(index)),
                     .CompanyName = items(System.Threading.Interlocked.Increment(index)),
                     .Address = items(System.Threading.Interlocked.Increment(index)),
                     .City = items(System.Threading.Interlocked.Increment(index)),
                     .Region = items(System.Threading.Interlocked.Increment(index)),
                     .PostalCode = items(System.Threading.Interlocked.Increment(index)),
                     .Country = items(System.Threading.Interlocked.Increment(index)),
                     .Salesperson = items(System.Threading.Interlocked.Increment(index)),
                     .OrderID = UInteger.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .OrderDate = DateTime.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .Weekday = DirectCast([Enum].Parse(GetType(DayOfWeek), items(System.Threading.Interlocked.Increment(index)), True), DayOfWeek),
                     .RequiredDate = DateTime.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .ShippedDate = DateTime.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .Shipper = items(System.Threading.Interlocked.Increment(index)),
                     .ProductID = UInteger.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .ProductName = items(System.Threading.Interlocked.Increment(index)),
                     .UnitPrice = Decimal.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .Quantity = UInteger.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .Discount = Decimal.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .ExtendedPrice = Decimal.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .Freight = Decimal.Parse(items(System.Threading.Interlocked.Increment(index)), CultureInfo.InvariantCulture),
                     .ShipName = items(System.Threading.Interlocked.Increment(index)),
                     .ShipAddress = items(System.Threading.Interlocked.Increment(index)),
                     .ShipCity = items(System.Threading.Interlocked.Increment(index)),
                     .ShipRegion = items(System.Threading.Interlocked.Increment(index)),
                     .ShipPostalCode = items(System.Threading.Interlocked.Increment(index)),
                     .ShipCountry = items(System.Threading.Interlocked.Increment(index)),
                     .CategoryName = items(System.Threading.Interlocked.Increment(index))
                }
                list.Add(invoice_)
            End While
        End Using

        Return list
    End Function
End Class