HasUnprocessedChanges method

bool HasUnprocessedChanges()
Determines whether there are any unsaved attachment collection changes.

Implementation

bool HasUnprocessedChanges() {
  // Any new attachments?
  for (Attachment attachment in this) {
    if (attachment.IsNew) {
      return true;
    }
  }

  // Any pending deletions?
  for (Attachment? attachment in this.RemovedItems) {
    if (!attachment!.IsNew) {
      return true;
    }
  }

  // Recurse: process item attachments to check for new or deleted sub-attachments.
  for (ItemAttachment itemAttachment in this.OfType<ItemAttachment>()) {
    if (itemAttachment.Item != null) {
      if (itemAttachment.Item!.Attachments.HasUnprocessedChanges()) {
        return true;
      }
    }
  }

  return false;
}