Back to Devexpress

AppointmentXmlPersistenceHelper.ObjectFromXml(IAppointmentStorageBase, String) Method

corelibraries-devexpress-dot-xtrascheduler-dot-xml-dot-appointmentxmlpersistencehelper-dot-objectfromxml-x28-devexpress-dot-xtrascheduler-dot-iappointmentstoragebase-system-dot-string-x29.md

latest5.1 KB
Original Source

AppointmentXmlPersistenceHelper.ObjectFromXml(IAppointmentStorageBase, String) Method

Restores an appointment from an XML serialized string.

Namespace : DevExpress.XtraScheduler.Xml

Assembly : DevExpress.XtraScheduler.v25.2.Core.dll

NuGet Package : DevExpress.Scheduler.Core

Declaration

csharp
public static Appointment ObjectFromXml(
    IAppointmentStorageBase storage,
    string xml
)
vb
Public Shared Function ObjectFromXml(
    storage As IAppointmentStorageBase,
    xml As String
) As Appointment

Parameters

NameTypeDescription
storageIAppointmentStorageBase

An ISchedulerStorageBase object that provides an appointment factory, custom field mappings and time zone translation.

| | xml | String |

A string in XML format containing the serialized appointment.

|

Returns

TypeDescription
Appointment

An Appointment object created from the string.

|

Remarks

Use the ObjectFromXml method to de-serialize an appointment serialized with the XtraScheduler.Xml.XmlPersistenceHelper.ToXml method.

Example

The code sample demonstrates how to deserialize an appointment, i.e., to restore it from an XML string stored in the data source bound to the scheduler.

csharp
scheduler.Storage.Appointments.Clear();
            string xmlAppointment = @"<Appointment Version=""1"" Start=""01/13/2016 04:22:00"" 
End=""01/13/2016 05:53:00"" Label=""5"" ResourceId=""3"" Status=""2"" Subject=""Meet Andrew Miller"" />";
            Appointment objAppointment = AppointmentXmlPersistenceHelper.ObjectFromXml(scheduler.Storage.Appointments, xmlAppointment);
            scheduler.Storage.Appointments.Add(objAppointment);
            scheduler.Start = new DateTime(2016, 1, 13);
vb
scheduler.Storage.Appointments.Clear()
            Dim xmlAppointment As String = "<Appointment Version=""1"" Start=""01/13/2016 04:22:00"" " & ControlChars.CrLf & _
"End=""01/13/2016 05:53:00"" Label=""5"" ResourceId=""3"" Status=""2"" Subject=""Meet Andrew Miller"" />"
            Dim objAppointment As Appointment = AppointmentXmlPersistenceHelper.ObjectFromXml(scheduler.Storage.Appointments, xmlAppointment)
            scheduler.Storage.Appointments.Add(objAppointment)
            scheduler.Start = New Date(2016, 1, 13)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ObjectFromXml(IAppointmentStorageBase, String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-scheduler-serialize-deserialize-appointments/CS/DXApplication1/SerializationHelper.cs#L35

csharp
{
    Appointment objAppointment = AppointmentXmlPersistenceHelper.ObjectFromXml(scheduler.DataStorage.Appointments, xmlAppointment);
    scheduler.DataStorage.Appointments.Add(objAppointment);

winforms-scheduler-serialize-deserialize-appointments/VB/DXApplication1/SerializationHelper.vb#L27

vb
For Each xmlAppointment As String In serializedAppointments
    Dim objAppointment As Appointment = AppointmentXmlPersistenceHelper.ObjectFromXml(scheduler.DataStorage.Appointments, xmlAppointment)
    scheduler.DataStorage.Appointments.Add(objAppointment)

See Also

AppointmentXmlPersistenceHelper Class

AppointmentXmlPersistenceHelper Members

DevExpress.XtraScheduler.Xml Namespace