LoadFromXml method

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

Implementation

void LoadFromXml(EwsXmlReader reader) {
  do {
    reader.Read();

    if (reader.NodeType == XmlNodeType.Element) {
      switch (reader.LocalName) {
        case XmlElementNames.AccountType:
          this.AccountType = reader.ReadElementValue<String>();
          break;
        case XmlElementNames.Action:
          String? xmlResponseType = 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();
          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 = reader.ReadElementValue<String>();
          break;
        case XmlElementNames.AlternateMailboxes:
          AlternateMailbox alternateMailbox =
              AlternateMailbox.LoadFromXml(reader);
          this._alternateMailboxes!.Entries.add(alternateMailbox);
          break;

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