-
Notifications
You must be signed in to change notification settings - Fork 0
/
SerializationHelper.vb
37 lines (30 loc) · 1.52 KB
/
SerializationHelper.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Xml
Imports System.Collections.Generic
Namespace DXApplication1
Friend Class SerializationHelper
Private Shared serializedAppointments As List(Of String) = New List(Of String)()
Public Shared Sub AppointmentSerialization(ByVal scheduler As SchedulerControl)
'#Region "#AppointmentSerialization"
SchedulerCompatibility.Base64XmlObjectSerialization = True
For Each apt As Appointment In scheduler.ActiveView.GetAppointments()
Dim helper As AppointmentXmlPersistenceHelper = New AppointmentXmlPersistenceHelper(apt, Nothing)
Call serializedAppointments.Add(helper.ToXml())
Next
scheduler.DataStorage.Appointments.Clear()
'#End Region ' #AppointmentSerialization
End Sub
Public Shared Sub AppointmentDeserialization(ByVal scheduler As SchedulerControl)
'#Region "#AppointmentDeserialization"
If serializedAppointments.Count > 0 Then
For Each xmlAppointment As String In serializedAppointments
Dim objAppointment As Appointment = AppointmentXmlPersistenceHelper.ObjectFromXml(scheduler.DataStorage.Appointments, xmlAppointment)
scheduler.DataStorage.Appointments.Add(objAppointment)
scheduler.Start = Date.Today
Next
End If
Call serializedAppointments.Clear()
'#End Region ' #AppointmentDeserialization
End Sub
End Class
End Namespace