importzugferdfiles: fix conversion error

This commit is contained in:
Jonathan Jenne 2019-05-10 15:31:03 +02:00
parent 15c33b843e
commit 2e19d878e0
2 changed files with 10 additions and 14 deletions

View File

@ -288,12 +288,16 @@ Public Class ImportZUGFeRDFiles
ToDictionary(Function(Item) Item.Key, ToDictionary(Function(Item) Item.Key,
Function(Item) Item.Value) Function(Item) Item.Value)
_logger.Debug("Found {0} default properties.", oDefaultProperties.Count)
' PropertyMap items with `IsGrouped = True` are grouped by group scope ' PropertyMap items with `IsGrouped = True` are grouped by group scope
Dim oGroupedProperties = args.PropertyMap. Dim oGroupedProperties = args.PropertyMap.
Where(Function(Item) Item.Value.IsGrouped = True). Where(Function(Item) Item.Value.IsGrouped = True).
ToLookup(Function(Item) Item.Value.GroupScope, ' Lookup key is group scope ToLookup(Function(Item) Item.Value.GroupScope, ' Lookup key is group scope
Function(Item) Item) Function(Item) Item)
_logger.Debug("Found {0} properties grouped in {1} group(s)", args.PropertyMap.Count - oDefaultProperties.Count, oGroupedProperties.Count)
' Iterate through groups to get group scope and group items ' Iterate through groups to get group scope and group items
For Each oGroup In oGroupedProperties For Each oGroup In oGroupedProperties
Dim oGroupScope = oGroup.Key Dim oGroupScope = oGroup.Key
@ -355,7 +359,10 @@ Public Class ImportZUGFeRDFiles
' Iterate through default properties ' Iterate through default properties
For Each Item As KeyValuePair(Of String, XmlItemProperty) In oDefaultProperties For Each Item As KeyValuePair(Of String, XmlItemProperty) In oDefaultProperties
Dim oPropertyValue As String = PropertyValues.GetPropValue(oDocument, Item.Key) Dim oPropertyValueList As List(Of Object) = PropertyValues.GetPropValue(oDocument, Item.Key)
Dim oPropertyValue = oPropertyValueList.
DefaultIfEmpty(New List(Of Object) From {Nothing}).
First()
Dim oPropertyDescription As String = Item.Value.Description Dim oPropertyDescription As String = Item.Value.Description
If String.IsNullOrEmpty(oPropertyValue) Then If String.IsNullOrEmpty(oPropertyValue) Then

View File

@ -6,18 +6,7 @@ Public Class PropertyValues
Private Shared _indexPattern = "\((\d+)\)" Private Shared _indexPattern = "\((\d+)\)"
Private Shared _indexRegex As New Regex(_indexPattern) Private Shared _indexRegex As New Regex(_indexPattern)
Public Shared Function GetPropValues(Obj As Object, PropertyName As String) Public Shared Function GetPropValue(Obj As Object, PropertyName As String) As List(Of Object)
Dim oResult As Object = GetPropValue(Obj, PropertyName)
' Wrap the result of `GetPropValue` in a list if a single Value is returned
If TypeOf oResult Is List(Of Object) Then
Return oResult
Else
Return New List(Of Object) From {oResult}
End If
End Function
Public Shared Function GetPropValue(Obj As Object, PropertyName As String)
Dim oNameParts As String() = PropertyName.Split("."c) Dim oNameParts As String() = PropertyName.Split("."c)
If IsNothing(Obj) Then If IsNothing(Obj) Then
@ -78,7 +67,7 @@ Public Class PropertyValues
End If End If
Next Next
Return Obj Return New List(Of Object) From {Obj}
End Function End Function
Private Shared Function GetIndex(Prop As String) As Integer Private Shared Function GetIndex(Prop As String) As Integer