TryReadElementFromXml method

  1. @override
Future<bool> TryReadElementFromXml(
  1. EwsServiceXmlReader reader
)
override
Tries to read element from XML. The reader.

Implementation

@override
Future<bool> TryReadElementFromXml(EwsServiceXmlReader reader) async {
  bool result = await super.TryReadElementFromXml(reader);

  if (!result) {
    if (reader.LocalName == XmlElementNames.IsContactPhoto) {
      this._isContactPhoto = await reader.ReadElementValue<bool>();
    } else if (reader.LocalName == XmlElementNames.Content) {
      if (this._loadToStream != null) {
        reader.ReadBase64ElementValueWithStream(this._loadToStream);
      } else {
        // If there's a file attachment content handler, use it. Otherwise
        // load the content into a byte array.
        // TODO: Should we mark the attachment to indicate that content is stored elsewhere?
        if (reader.Service.FileAttachmentContentHandler != null) {
          Stream outputStream = reader.Service.FileAttachmentContentHandler!
              .GetOutputStream(this.Id);

          if (outputStream != null) {
            reader.ReadBase64ElementValueWithStream(outputStream);
          } else {
            this._content = await reader.ReadBase64ElementValue();
          }
        } else {
          this._content = await reader.ReadBase64ElementValue();
        }
      }

      result = true;
    }
  }

  return result;
}