Table of Contents

MapiPropertyCollection Class

Definition

Namespace
Bodu.Formats.Outlook
Assembly
Bodu.Formats.Outlook.dll
Package
Bodu.Formats.Outlook 0.7.1
Source
MapiPropertyCollection.cs

Provides a read-only, tag-addressed collection of decoded MAPI properties with typed convenience accessors.

public sealed class MapiPropertyCollection : IReadOnlyCollection<MapiProperty>, IEnumerable<MapiProperty>, IEnumerable
Inheritance
MapiPropertyCollection
Implements
Inherited Members
Extension Methods

Remarks

Lookup is keyed by the full 32-bit MapiPropertyTag - identifier and type together. The typed accessors probe the plausible wire types for an identifier (for example, GetString(ushort) probes Unicode and then String8) and return null when the property is absent or its stored value is not of the requested CLR type - they never throw for a missing or mismatched property.

When the constructor input carries the same tag more than once, the last occurrence wins. Enumeration preserves first-occurrence order.

Constructors

MapiPropertyCollection(IEnumerable<MapiProperty>)

Initializes a new instance of the MapiPropertyCollection class.

public MapiPropertyCollection(IEnumerable<MapiProperty> properties)

Parameters

properties IEnumerable<MapiProperty>

The decoded properties. Must not be null.

Exceptions

ArgumentNullException

Thrown if properties or one of its elements is null.

Properties

Count

Gets the number of properties in the collection.

public int Count { get; }

Property Value

int

The property count.

Empty

Gets an empty property collection.

public static MapiPropertyCollection Empty { get; }

Property Value

MapiPropertyCollection

A shared collection containing no properties.

Methods

Contains(MapiPropertyTag)

Determines whether the collection contains a property with the given tag.

public bool Contains(MapiPropertyTag tag)

Parameters

tag MapiPropertyTag

The full property tag to look up.

Returns

bool

true when a property with the tag is present.

GetAll(ushort)

Enumerates every property carrying a 16-bit identifier, in first-occurrence order - one per distinct type the writer stored it under.

public IEnumerable<MapiProperty> GetAll(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

IEnumerable<MapiProperty>

The matching properties; empty when none is present.

GetBinary(ushort)

Returns the binary value of a property.

public ReadOnlyMemory<byte>? GetBinary(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

ReadOnlyMemory<byte>?

The payload bytes, or null when absent or not binary.

GetBoolean(ushort)

Returns the Boolean value of a property.

public bool? GetBoolean(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

bool?

The value, or null when absent or not a Boolean.

GetDateTime(ushort)

Returns the time-stamp value of a property.

public DateTimeOffset? GetDateTime(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

DateTimeOffset?

The value, or null when absent or not a time stamp.

GetDouble(ushort)

Returns the floating-point value of a property, probing the 64-bit and then the 32-bit type.

public double? GetDouble(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

double?

The value (a 32-bit value is widened), or null when absent or not floating-point.

GetEnumerator()

Returns an enumerator over the properties in first-occurrence order.

public IEnumerator<MapiProperty> GetEnumerator()

Returns

IEnumerator<MapiProperty>

The property enumerator.

GetGuid(ushort)

Returns the GUID value of a property.

public Guid? GetGuid(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

Guid?

The value, or null when absent or not a GUID.

GetInt32(ushort)

Gets a 32-bit integer property value.

public int? GetInt32(ushort id)

Parameters

id ushort

The property identifier.

Returns

int?

The Int32 value, or the Int16 value widened when the writer stored the property in the narrower type; null when neither is present.

GetInt64(ushort)

Gets a 64-bit integer property value.

public long? GetInt64(ushort id)

Parameters

id ushort

The property identifier.

Returns

long?

The Int64 value, or the Int32 or Int16 value widened when the writer stored the property in a narrower type; null when none is present.

GetString(ushort)

Returns the string value of a property, probing the Unicode and then the code-page string type.

public string? GetString(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

string

The string value, or null when absent or not a string.

GetStringArray(ushort)

Returns the multi-valued string value of a property, probing the Unicode and then the code-page string type.

public string[]? GetStringArray(ushort id)

Parameters

id ushort

The 16-bit property identifier.

Returns

string[]

The string values, or null when absent or not a multi-valued string.

TryGetValue(MapiPropertyTag, out MapiProperty)

Attempts to retrieve the property with the given tag.

public bool TryGetValue(MapiPropertyTag tag, out MapiProperty property)

Parameters

tag MapiPropertyTag

The full property tag to look up.

property MapiProperty

When this method returns, the matching property when one is present.

Returns

bool

true when a property with the tag is present.

TryGetValue(ushort, out MapiProperty)

Attempts to retrieve the first property carrying a 16-bit identifier, whatever its type - the lookup for callers that know which property they want but not which wire type the writer chose for it.

public bool TryGetValue(ushort id, out MapiProperty property)

Parameters

id ushort

The 16-bit property identifier.

property MapiProperty

When this method returns, the first matching property when one is present.

Returns

bool

true when a property with the identifier is present.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns a non-generic enumerator over the properties.

IEnumerator IEnumerable.GetEnumerator()

Returns

IEnumerator

The property enumerator.

Applies to

ProductVersions
.NET8, 10