LoadFromXml method

Future<void> LoadFromXml(
  1. EwsXmlReader reader
)
Load from XML. The reader.

Implementation

Future<void> LoadFromXml(EwsXmlReader reader) async {
  do {
    await reader.Read();

    if (reader.NodeType == XmlNodeType.Element) {
      switch (reader.LocalName) {
        case XmlElementNames.AccountType:
          this.AccountType = await reader.ReadElementValue<String>();
          break;
        case XmlElementNames.Action:
          String? xmlResponseType = await reader.ReadElementValue<String>();

          switch (xmlResponseType) {
            case OutlookAccount._Settings:
              this.ResponseType = AutodiscoverResponseType.Success;
              break;
            case OutlookAccount._RedirectUrl:
              this.ResponseType = AutodiscoverResponseType.RedirectUrl;
              break;
            case OutlookAccount._RedirectAddr:
              this.ResponseType = AutodiscoverResponseType.RedirectAddress;
              break;
            default:
              this.ResponseType = AutodiscoverResponseType.Error;
              break;
          }

          break;
        case XmlElementNames.Protocol:
          OutlookProtocol protocol = new OutlookProtocol();
          await protocol.LoadFromXml(reader);
          if (this._protocols.containsKey(protocol.ProtocolType)) {
            // There should be strictly one node per protocol type in the autodiscover response.
            throw new ServiceLocalException(
                "Strings.InvalidAutodiscoverServiceResponse");
          }
          this._protocols[protocol.ProtocolType] = protocol;
          break;
        case XmlElementNames.RedirectAddr:
        case XmlElementNames.RedirectUrl:
          this.RedirectTarget = await reader.ReadElementValue<String>();
          break;
        case XmlElementNames.AlternateMailboxes:
          AlternateMailbox alternateMailbox =
              await AlternateMailbox.LoadFromXml(reader);
          this._alternateMailboxes!.Entries.add(alternateMailbox);
          break;

        default:
          await reader.SkipCurrentElement();
          break;
      }
    }
  } while (!reader.IsEndElementWithNamespace(
      XmlNamespace.NotSpecified, XmlElementNames.Account));
}