MetadataBlob Class

An immutable sequence of metadata bytes (EXIF, XMP, ICC...).

public sealed class MetadataBlob : IEquatable<MetadataBlob>

Remarks

The constructor copies its input, so the caller cannot mutate the blob afterward. Because blobs are immutable, metadata clones share them instead of copying them. Blobs created by callers are validated when they are serialized, not when they are constructed, and are caller allocations rather than part of an image allocation budget. Equality compares the bytes.

Implements

Constructors

NameDescription
MetadataBlob(ReadOnlySpan<byte>)Initializes a new instance of the MetadataBlob class by copying the specified bytes.

MetadataBlob(ReadOnlySpan<byte>)

MetadataBlob.cs

Initializes a new instance of the MetadataBlob class by copying the specified bytes.

public MetadataBlob(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>
The bytes to copy.

Properties

NameDescription
LengthGets the number of bytes.
MemoryGets the bytes as read-only memory.
SpanGets the bytes as a read-only span.

Gets the number of bytes.

public int Length { get; }

Property value

int

Gets the bytes as read-only memory.

public ReadOnlyMemory<byte> Memory { get; }

Property value

ReadOnlyMemory<byte>

Gets the bytes as a read-only span.

public ReadOnlySpan<byte> Span { get; }

Property value

ReadOnlySpan<byte>

Methods

NameDescription
Equals(MetadataBlob?)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Determines whether the specified object is equal to the current object.
GetHashCode()Serves as the default hash function.
ToArray()Copies the bytes to a new array.

Equals overloads

Equals(MetadataBlob?)

MetadataBlob.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(MetadataBlob? other)
Parameters
other MetadataBlob?
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

MetadataBlob.cs

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current object.
Returns

bool true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

MetadataBlob.cs

Serves as the default hash function.

public override int GetHashCode()

Returns

int A hash code for the current object.

Copies the bytes to a new array.

public byte[] ToArray()

Returns

byte[] A new array containing a copy of the bytes.