Class BinaryFile
Represents a binary file.
public sealed class BinaryFile : ValueObject
- Inheritance
-
BinaryFile
- Inherited Members
Constructors
BinaryFile(byte[])
Initializes a new instance of the BinaryFile class.
public BinaryFile(byte[] content)
Parameters
content
byte[]Content.
BinaryFile(byte[], string?, IReadOnlyDictionary<string, object>?)
Initializes a new instance of the BinaryFile class.
public BinaryFile(byte[] content, string? mimeType, IReadOnlyDictionary<string, object>? metadata = null)
Parameters
content
byte[]Content.
mimeType
stringMime type.
metadata
IReadOnlyDictionary<string, object>Metadata.
BinaryFile(string?, byte[], string?, IReadOnlyDictionary<string, object>?)
Initializes a new instance of the BinaryFile class.
public BinaryFile(string? name, byte[] content, string? mimeType = null, IReadOnlyDictionary<string, object>? metadata = null)
Parameters
name
stringName.
content
byte[]Content.
mimeType
stringMime type.
metadata
IReadOnlyDictionary<string, object>Metadata.
Properties
Content
Gets the content.
public byte[] Content { get; init; }
Property Value
- byte[]
Empty
Gets an empty binary file.
public static BinaryFile Empty { get; }
Property Value
Metadata
Gets the file metadata.
public IReadOnlyDictionary<string, object> Metadata { get; init; }
Property Value
MimeType
Gets the document mime type.
public string MimeType { get; }
Property Value
Name
Gets the file name with extension.
public string? Name { get; init; }
Property Value
Methods
GetEqualityComponents()
Gets equality components.
protected override IEnumerable<object?> GetEqualityComponents()
Returns
- IEnumerable<object>
The components.
WithMetadata(string, object)
Adds a metadata to binary file.
public BinaryFile WithMetadata(string key, object value)
Parameters
Returns
- BinaryFile
The new instance.
WithMimeType(string)
Set the MIME type.
public BinaryFile WithMimeType(string mimeType)
Parameters
mimeType
stringThe MIME type.
Returns
- BinaryFile
The same instance if MIME type is up to date or if previous MIME type is application/octet-stream, a new instance otherwise.