Table of Contents

Class BinaryFile

Namespace
GroupeIsa.Neos.Shared.IO
Assembly
GroupeIsa.Neos.Shared.dll

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 string

Mime 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 string

Name.

content byte[]

Content.

mimeType string

Mime 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

BinaryFile

Metadata

Gets the file metadata.

public IReadOnlyDictionary<string, object> Metadata { get; init; }

Property Value

IReadOnlyDictionary<string, object>

MimeType

Gets the document mime type.

public string MimeType { get; }

Property Value

string

Name

Gets the file name with extension.

public string? Name { get; init; }

Property Value

string

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

key string

The metadata key.

value object

The metadata value.

Returns

BinaryFile

The new instance.

WithMimeType(string)

Set the MIME type.

public BinaryFile WithMimeType(string mimeType)

Parameters

mimeType string

The 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.