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 = new NotificationGroup();
    notifications.SubscriptionId = await reader.ReadElementValueWithNamespace(
        XmlNamespace.Types, XmlElementNames.SubscriptionId);
    notifications.Events = <NotificationEvent>[];

    this.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 this.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));
}