TryReadElementFromXml method

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

Implementation

@override
bool TryReadElementFromXml(EwsServiceXmlReader reader) {
  bool result = super.TryReadElementFromXml(reader);

  if (!result) {
    if (reader.LocalName == XmlElementNames.IsContactPhoto) {
      this._isContactPhoto = 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 = reader.ReadBase64ElementValue();
          }
        } else {
          this._content = reader.ReadBase64ElementValue();
        }
      }

      result = true;
    }
  }

  return result;
}