Refactor: Add ImporterShared Project

This commit is contained in:
Jonathan Jenne
2021-08-18 13:19:10 +02:00
parent 3abf4b6e87
commit 55e921eb21
38 changed files with 1497 additions and 981 deletions

47
ImporterShared/Mapper.vb Normal file
View File

@@ -0,0 +1,47 @@
Imports System.Globalization
Imports AutoMapper
Imports AutoMapper.Configuration
Public Class Mapper
Private Shared MapperConfig As Object
Public Shared Function GetMapper()
MapperConfig = New MapperConfiguration(CreateMapperConfig())
MapperConfig.AssertConfigurationIsValid()
Return MapperConfig.CreateMapper()
End Function
Private Shared Function CreateMapperConfig() As MapperConfigurationExpression
Dim oConfig As New MapperConfigurationExpression()
oConfig.CreateMap(Of String, Integer)().ConvertUsing(New IntegerTypeConverter())
oConfig.CreateMap(Of String, Decimal)().ConvertUsing(New DecimalTypeConverter())
oConfig.CreateMap(Of String, DateTime)().ConvertUsing(New DateTimeTypeConverter())
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebService, Schemas.Orders.Output.MESOWebService)()
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)()
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT026, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)()
Return oConfig
End Function
Private Class DateTimeTypeConverter
Implements ITypeConverter(Of String, DateTime)
Public Function Convert(source As String, destination As Date, context As ResolutionContext) As Date Implements ITypeConverter(Of String, Date).Convert
Return System.Convert.ToDateTime(source)
End Function
End Class
Private Class IntegerTypeConverter
Implements ITypeConverter(Of String, Integer)
Public Function Convert(source As String, destination As Integer, context As ResolutionContext) As Integer Implements ITypeConverter(Of String, Integer).Convert
Return System.Convert.ToInt32(source)
End Function
End Class
Private Class DecimalTypeConverter
Implements ITypeConverter(Of String, Decimal)
Public Function Convert(source As String, destination As Decimal, context As ResolutionContext) As Decimal Implements ITypeConverter(Of String, Decimal).Convert
Return System.Convert.ToDecimal(source, CultureInfo.InvariantCulture)
End Function
End Class
End Class