Imports System.ComponentModel
Imports System.Globalization

Public Class IndexListConverter
    Inherits TypeConverter

    Public Overrides Function GetStandardValuesSupported(context As ITypeDescriptorContext) As Boolean
        Return True
    End Function

    Public Overrides Function GetStandardValues(context As ITypeDescriptorContext) As StandardValuesCollection
        Dim indexList = New List(Of String)

        If TypeOf (context.Instance) Is FinalIndexProperties Then
            indexList = DirectCast(context.Instance, FinalIndexProperties).Indicies
        ElseIf TypeOf (context.Instance) Is InputProperties Then
            indexList = DirectCast(context.Instance, InputProperties).Indicies
        End If

        Dim values As New StandardValuesCollection(indexList)
        Return values
    End Function

    Public Overrides Function ConvertTo(context As ITypeDescriptorContext, culture As CultureInfo, value As Object, destinationType As Type) As Object
        If IsNothing(value) Then
            Return ""
        Else
            Return value.ToString()
        End If
    End Function
End Class
