Imports System.IO Imports System.Xml.Serialization Imports TA_OR_rework.rework Module ReworkTraySlotMapperXML Public Function getDataFromFile() As List(Of Slot) Try Dim serializer As New XmlSerializer(GetType(List(Of Slot)), New XmlRootAttribute("")) Dim deserialized As List(Of Slot) = Nothing deserialized = DirectCast(serializer.Deserialize(New FileStream(getPath(), FileMode.Open, FileAccess.Read, FileShare.Read)), List(Of Slot)) Return New List(Of Slot)(deserialized) Catch ex As Exception Throw New Exception("Er is iets foutgelopen bij serializeren van het bestand ReworkTraySlots.xml. " & ex.Message) End Try Return Nothing End Function Public Sub writeToFile(slots As List(Of Slot)) Dim serializer As New Xml.Serialization.XmlSerializer(slots.GetType) serializer.Serialize(New FileStream(getPath(), FileMode.OpenOrCreate), slots) End Sub Private Function getPath() As String Dim strPath As String = My.Settings.PathNaarConfigMap Dim fileName As String = "ReworkTraySlots.xml" Dim fullPath = Path.Combine(strPath, fileName) Return fullPath End Function ' Public Sub vulBestand() ' Dim slot1 As New Slot(1) ' slot1.type = SlotType.dubbel ' Dim slot2 As New Slot(2) ' slot2.type = SlotType.dubbel ' Dim slot3 As New Slot(3) ' slot3.type = SlotType.dubbel ' Dim slot4 As New Slot(4) ' slot4.type = SlotType.dubbel ' Dim slot5 As New Slot(5) ' slot5.type = SlotType.enkel ' Dim slot6 As New Slot(6) ' slot6.type = SlotType.enkel ' Dim slots As New List(Of Slot) ' slots.Add(slot1) ' slots.Add(slot2) ' slots.Add(slot3) ' slots.Add(slot4) ' slots.Add(slot5) ' slots.Add(slot6) ' ReworkTraySlotMapperXML.writeToFile(slots) 'End Sub End Module