Class AttachmentContainer
A container for attachment files, which may or may not have been downloaded into local memory or storage.
Inherited Members
Namespace: CrashCABN.Metadata
Assembly: CrashCABN.Metadata.Attachments.dll
Syntax
public sealed class AttachmentContainer : IAttachmentContainer, IEnumerable<AttachmentInfo>, IEnumerable
Remarks
Initializes a new instance of the AttachmentContainer class.
Constructors
View SourceAttachmentContainer(params AttachmentInfo[])
Initializes a new instance of the AttachmentContainer class.
Declaration
public AttachmentContainer(params AttachmentInfo[] attachments)
Parameters
Type | Name | Description |
---|---|---|
AttachmentInfo[] | attachments | The attachments. |
AttachmentContainer(IAttachmentProcessor, params AttachmentInfo[])
A container for attachment files, which may or may not have been downloaded into local memory or storage.
Declaration
public AttachmentContainer(IAttachmentProcessor processor, params AttachmentInfo[] attachments)
Parameters
Type | Name | Description |
---|---|---|
IAttachmentProcessor | processor | The attachment processor. |
AttachmentInfo[] | attachments | The attachments. |
Remarks
Initializes a new instance of the AttachmentContainer class.
Methods
View SourceGetEnumerator()
Gets the attachments.
Declaration
public IEnumerator<AttachmentInfo> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<AttachmentInfo> |
Load(string)
Loads an attachment from the IAttachmentContainer.
Declaration
public ValueTask<object> Load(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attachment to load. |
Returns
Type | Description |
---|---|
ValueTask<object> | A task representing the attachment contents. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Thrown if the attachment is missing. |
Load<T>(string)
Loads a typed attachment from the IAttachmentContainer.
Declaration
public ValueTask<T> Load<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attachment to load. |
Returns
Type | Description |
---|---|
ValueTask<T> | A task representing the attachment contents. |
Type Parameters
Name | Description |
---|---|
T | The type of the attachment to load. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Thrown if the attachment is missing. |
InvalidCastException | Thrown if the attachment is not of the given type. |
TryGetInfo(string)
Gets the attachment info.
Declaration
public AttachmentInfo? TryGetInfo(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attachment. |
Returns
Type | Description |
---|---|
AttachmentInfo | The info, if it exists. |
TryLoad(string)
Loads an attachment from the IAttachmentContainer.
Declaration
public ValueTask<object?> TryLoad(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attachment to load. |
Returns
Type | Description |
---|---|
ValueTask<object> | A task representing the attachment contents, or null if the attachment was missing. |