AddItemAttachment<TItem extends Item> method
Adds a reference attachment to the collection
The display name of the new attachment.
The fully-qualified path identifying the attachment
Adds an item attachment to the collection
Implementation
// ReferenceAttachment AddReferenceAttachment(
// String name,
// String attachLongPathName)
// {
// ReferenceAttachment referenceAttachment = new ReferenceAttachment(this.owner);
//
// referenceAttachment.Name = name;
// referenceAttachment.AttachLongPathName = attachLongPathName;
//
// this.InternalAdd(referenceAttachment);
//
// return referenceAttachment;
// }
/// <summary>
/// Adds an item attachment to the collection
/// </summary>
/// <typeparam name="TItem">The type of the item to attach.</typeparam>
/// <returns>An ItemAttachment instance.</returns>
GenericItemAttachment<TItem> AddItemAttachment<TItem extends Item>() {
// Dart has no attribute reflection; these are the item classes marked
// [Attachable] in the C# API.
if (!_attachableItemTypes.contains(TItem)) {
throw InvalidOperationException(
"Items of type $TItem are not supported as attachments.",
);
}
GenericItemAttachment<TItem> itemAttachment = GenericItemAttachment<TItem>(
_owner!,
);
itemAttachment.Item = EwsUtilities.CreateItemFromItemClass(
itemAttachment,
TItem,
true,
) as TItem;
InternalAdd(itemAttachment);
return itemAttachment;
}