jj: first pass of final index redesign
This commit is contained in:
@@ -1,3 +1,73 @@
|
||||
Public Class ClassFinalIndex
|
||||
Public Shared PREFIX_VECTOR = "[%VKT"
|
||||
|
||||
Public Shared Function GetValue(obj As Object, indexName As String, indcies As List(Of String), types As List(Of Integer), isVector As Boolean)
|
||||
Try
|
||||
Dim props As FinalIndexProperties = obj
|
||||
Dim i As Integer = indcies.IndexOf(indexName)
|
||||
Dim type As Integer = types.Item(i)
|
||||
Dim value As String = ""
|
||||
|
||||
If type = INDEX_TYPE_STRING Or type = INDEX_TYPE_VECTOR_STRING Then
|
||||
value = props.StringValue
|
||||
ElseIf type = INDEX_TYPE_INTEGER Or type = INDEX_TYPE_VECTOR_INTEGER Then
|
||||
value = props.IntegerValue.ToString
|
||||
ElseIf type = INDEX_TYPE_FLOAT Then
|
||||
value = props.FloatValue.ToString
|
||||
ElseIf type = INDEX_TYPE_BOOLEAN Or type = INDEX_TYPE_VECTOR_BOOLEAN Then
|
||||
value = IIf(props.BoolValue, "1", "0")
|
||||
End If
|
||||
|
||||
If isVector Then
|
||||
Return $"{PREFIX_VECTOR}{value}"
|
||||
Else
|
||||
Return value
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox($"Error in GetValue: {ex.Message}", MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function SetValue(value As String, obj As Object, indexName As String, indcies As List(Of String), types As List(Of Integer))
|
||||
Try
|
||||
Dim props As FinalIndexProperties = obj
|
||||
Dim i As Integer = indcies.IndexOf(indexName)
|
||||
Dim type As Integer = types.Item(i)
|
||||
Dim isVector = value.StartsWith(PREFIX_VECTOR)
|
||||
|
||||
If type = INDEX_TYPE_STRING Or type = INDEX_TYPE_VECTOR_STRING Then
|
||||
value = NotNull(value, "")
|
||||
|
||||
props.StringValue = value
|
||||
ElseIf type = INDEX_TYPE_INTEGER Or type = INDEX_TYPE_VECTOR_INTEGER Then
|
||||
value = NotNull(Of Integer)(value, 0)
|
||||
|
||||
If value = String.Empty Then
|
||||
props.IntegerValue = 0
|
||||
Else
|
||||
props.IntegerValue = Integer.Parse(value)
|
||||
End If
|
||||
ElseIf type = INDEX_TYPE_FLOAT Then
|
||||
value = NotNull(Of Double)(value, 0)
|
||||
|
||||
If value = String.Empty Then
|
||||
props.FloatValue = 0
|
||||
Else
|
||||
props.FloatValue = Double.Parse(value)
|
||||
End If
|
||||
ElseIf type = INDEX_TYPE_BOOLEAN Or type = INDEX_TYPE_VECTOR_BOOLEAN Then
|
||||
value = NotNull(value, "False")
|
||||
|
||||
If value = "1" Or value.ToLower = "true" Then
|
||||
props.BoolValue = True
|
||||
Else
|
||||
props.BoolValue = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return props
|
||||
Catch ex As Exception
|
||||
MsgBox($"Error in SetValue: {ex.Message}", MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user