Table of Contents

OlePropertySection Class

Definition

Namespace
Bodu.IO.Compound.PropertySets
Assembly
Bodu.IO.Compound.dll
Package
Bodu.IO.Compound 1.0.0
Source
OlePropertySection.cs

Represents a single section of an OLE property set - a format-identified group of properties keyed by property identifier (PID).

public sealed class OlePropertySection
Inheritance
OlePropertySection
Inherited Members
Extension Methods

Remarks

A property set contains one or two sections. The first carries the well-known properties (such as summary information); an optional second, user-defined section carries custom properties whose human-readable names are held in the section's PropertyNames dictionary.

Constructors

OlePropertySection(Guid, int)

Initializes a new instance of the OlePropertySection class for authoring, with no properties.

public OlePropertySection(Guid formatId, int codePage)

Parameters

formatId Guid

The section format identifier (FMTID).

codePage int

The code page used to encode ANSI strings in the section.

Properties

CodePage

Gets the code page used to decode ANSI (VT_LPSTR) strings in the section.

public int CodePage { get; }

Property Value

int

The section code page; 1252 when none is declared.

FormatId

Gets the format identifier (FMTID) of the section.

public Guid FormatId { get; }

Property Value

Guid

The section's format identifier.

this[int]

Gets the value of the property with the specified identifier.

public OlePropertyValue? this[int propertyId] { get; }

Parameters

propertyId int

The property identifier (PID).

Property Value

OlePropertyValue

The property value, or null when no such property exists.

Properties

Gets the decoded properties keyed by property identifier.

public IReadOnlyDictionary<int, OlePropertyValue> Properties { get; }

Property Value

IReadOnlyDictionary<int, OlePropertyValue>

A read-only dictionary of property identifier to value.

PropertyNames

Gets the property-name dictionary mapping property identifiers to human-readable names.

public IReadOnlyDictionary<int, string> PropertyNames { get; }

Property Value

IReadOnlyDictionary<int, string>

A read-only dictionary populated from the section's dictionary property; empty when the section declares no names.

Methods

GetNamedProperties()

Builds a dictionary of the section's named properties, joining the property-name dictionary with the decoded values.

public IReadOnlyDictionary<string, OlePropertyValue> GetNamedProperties()

Returns

IReadOnlyDictionary<string, OlePropertyValue>

A dictionary keyed by property name; only properties that have both a name and a value are included.

Remove(int)

Removes the property with the specified identifier.

public bool Remove(int propertyId)

Parameters

propertyId int

The property identifier (PID).

Returns

bool

true when a property was removed; otherwise false.

Set(int, OlePropertyValue)

Sets the value of the property with the specified identifier.

public void Set(int propertyId, OlePropertyValue value)

Parameters

propertyId int

The property identifier (PID).

value OlePropertyValue

The value to assign.

Exceptions

ArgumentNullException

Thrown when value is null.

SetName(int, string)

Assigns a human-readable name to a property identifier in this section's dictionary.

public void SetName(int propertyId, string name)

Parameters

propertyId int

The property identifier (PID).

name string

The human-readable name.

Exceptions

ArgumentNullException

Thrown when name is null.

TryGetValue(int, out OlePropertyValue)

Attempts to get the value of the property with the specified identifier.

public bool TryGetValue(int propertyId, out OlePropertyValue value)

Parameters

propertyId int

The property identifier (PID).

value OlePropertyValue

When this method returns true, the property value; otherwise null.

Returns

bool

true when the property exists; otherwise false.

Applies to

ProductVersions
.NET8, 10