LoadFromXml method

Future<void> LoadFromXml(
  1. EwsServiceXmlReader reader
)
Loads from XML. The reader.

Implementation

Future<void> LoadFromXml(EwsServiceXmlReader reader) async {
  await reader.ReadStartElementWithNamespace(
    XmlNamespace.Messages,
    XmlElementNames.Notification,
  );

  do {
    NotificationGroup notifications = NotificationGroup();
    notifications.SubscriptionId = await reader.ReadElementValueWithNamespace(
      XmlNamespace.Types,
      XmlElementNames.SubscriptionId,
    );
    notifications.Events = <NotificationEvent>[];

    events.add(notifications);

    do {
      await reader.Read();

      if (reader.IsStartElement()) {
        String eventElementName = reader.LocalName;

        if (GetEventsResults.XmlElementNameToEventTypeMap!.containsKey(
          eventElementName,
        )) {
          EventType? eventType = GetEventsResults
              .XmlElementNameToEventTypeMap![eventElementName];
          if (eventType == EventType.Status) {
            // We don't need to return status events
            await reader.ReadEndElementIfNecessary(
              XmlNamespace.Types,
              eventElementName,
            );
          } else {
            await LoadNotificationEventFromXml(
              reader,
              eventElementName,
              eventType,
              notifications,
            );
          }
        } else {
          await reader.SkipCurrentElement();
        }
      }
    } while (!reader.IsEndElementWithNamespace(
      XmlNamespace.Messages,
      XmlElementNames.Notification,
    ));

    await reader.Read();
  } while (!reader.IsEndElementWithNamespace(
    XmlNamespace.Messages,
    XmlElementNames.Notifications,
  ));
}