OlePropertySection Class
Definition
- Namespace
- Bodu.IO.Compound.PropertySets
- Assembly
- Bodu.IO.Compound.dll
- Package
- Bodu.IO.Compound 1.3.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.
[MS-OLEPS] defines a property identifier as an unsigned 32-bit value. An identifier at or above 0x80000000, such as
the PID_LOCALE (0x80000000) and PID_BEHAVIOR (0x80000003) Office writes in a user-defined section, is keyed by its
unchecked int value, unchecked((int)0x80000000), and is written back as the same 32 bits.
Constructors
OlePropertySection(Guid, int)
Initializes a new instance of the OlePropertySection class for authoring, with no properties.
public OlePropertySection(Guid formatId, int codePage)
Parameters
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;
1252when none is declared.
Remarks
Code pages 1200, 1201 and 65001 read and write ANSI strings as UTF-16 and UTF-8; every other code page uses the
encoding the shared framework's CodePagesEncodingProvider serves for it, such as
Windows-1252 or Shift-JIS (932), without registering that provider process-wide. A code page the provider does
not serve, and code page 0, read and write as Latin-1. A character the code page cannot represent is written as
a best-fit or ? replacement, so store such text as UnicodeString or in a
code page 65001 section.
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
propertyIdintThe 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
propertyIdintThe property identifier (PID).
Returns
Set(int, OlePropertyValue)
Sets the value of the property with the specified identifier.
public void Set(int propertyId, OlePropertyValue value)
Parameters
propertyIdintThe property identifier (PID).
valueOlePropertyValueThe value to assign.
Exceptions
- ArgumentNullException
Thrown when
valueis 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
Exceptions
- ArgumentNullException
Thrown when
nameis 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
propertyIdintThe property identifier (PID).
valueOlePropertyValueWhen this method returns true, the property value; otherwise null.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |