Table of Contents

OlePropertyValue Class

Definition

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

Represents a single typed value read from an OLE property set, the managed counterpart of a COM PROPVARIANT.

public sealed record OlePropertyValue : IEquatable<OlePropertyValue>
Inheritance
OlePropertyValue
Implements
Inherited Members
Extension Methods

Remarks

The decoded CLR value is exposed through Value and the strongly-typed accessor methods. Scalar values are boxed to their natural CLR type (for example int, string, or DateTimeOffset); vector values (IsVector) are exposed as an object array of element values. A Windows FILETIME is stored as its raw 100-nanosecond tick count, so it can be read either as a DateTimeOffset (a point in time) or a TimeSpan (an elapsed duration, as used by the total-edit-time property).

Constructors

OlePropertyValue()

public OlePropertyValue()

Properties

IsVector

Gets a value indicating whether this property carries a vector (array) of values rather than a single scalar.

public bool IsVector { get; init; }

Property Value

bool

true when Value is an object array; otherwise false.

Type

Gets the scalar value type of this property.

public OlePropertyType Type { get; init; }

Property Value

OlePropertyType

The OlePropertyType describing the decoded value.

Value

Gets the decoded value.

public object? Value { get; init; }

Property Value

object

The boxed CLR value for a scalar property, an object array for a vector property, or null for an empty or null value.

Methods

AsBoolean()

Returns the value as a boolean when it is a boolean scalar.

public bool? AsBoolean()

Returns

bool?

The boolean value, or null when the value is not a boolean.

AsBytes()

Returns the value as a byte array when it is a blob or clipboard scalar.

public byte[]? AsBytes()

Returns

byte[]

The byte array, or null when the value is not binary.

AsDateTimeOffset()

Returns the value as a point in time when it is a date or FILETIME scalar.

public DateTimeOffset? AsDateTimeOffset()

Returns

DateTimeOffset?

The time value, or null when the value is not a date or FILETIME.

AsInt32()

Returns the value as a 32-bit integer when it is an integral scalar.

public int? AsInt32()

Returns

int?

The integer value, or null when the value is not integral.

AsInt64()

Returns the value as a 64-bit integer when it is an integral scalar.

public long? AsInt64()

Returns

long?

The integer value, or null when the value is not integral.

AsString()

Returns the value as a string when it is a string scalar.

public string? AsString()

Returns

string

The string value, or null when the value is not a string.

AsTimeSpan()

Returns the value as an elapsed duration when it is a FILETIME scalar.

public TimeSpan? AsTimeSpan()

Returns

TimeSpan?

The duration, or null when the value is not a FILETIME.

Create(bool)

Creates a boolean property value.

public static OlePropertyValue Create(bool value)

Parameters

value bool

The boolean value.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(DateTimeOffset)

Creates a FILETIME property value from a point in time.

public static OlePropertyValue Create(DateTimeOffset value)

Parameters

value DateTimeOffset

The time to store.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(double)

Creates a 64-bit floating-point property value.

public static OlePropertyValue Create(double value)

Parameters

value double

The floating-point value.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(short)

Creates a 16-bit integer property value.

public static OlePropertyValue Create(short value)

Parameters

value short

The integer value.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(int)

Creates a 32-bit integer property value.

public static OlePropertyValue Create(int value)

Parameters

value int

The integer value.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(long)

Creates a 64-bit integer property value.

public static OlePropertyValue Create(long value)

Parameters

value long

The integer value.

Returns

OlePropertyValue

A new OlePropertyValue.

Create(string, OlePropertyType)

Creates a string property value.

public static OlePropertyValue Create(string value, OlePropertyType type = OlePropertyType.AnsiString)

Parameters

value string

The string value.

type OlePropertyType

The string property type; defaults to AnsiString.

Returns

OlePropertyValue

A new OlePropertyValue.

Exceptions

ArgumentNullException

Thrown when value is null.

CreateBlob(byte[])

Creates a blob property value.

public static OlePropertyValue CreateBlob(byte[] value)

Parameters

value byte[]

The blob bytes.

Returns

OlePropertyValue

A new OlePropertyValue.

Exceptions

ArgumentNullException

Thrown when value is null.

Equals(OlePropertyValue?)

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

public bool Equals(OlePropertyValue? other)

Parameters

other OlePropertyValue

An object to compare with this object.

Returns

bool

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

Equals(object?)

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()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetValueOrDefault<T>()

Returns the value as T when the boxed value is of that type.

public T? GetValueOrDefault<T>()

Returns

T

The value cast to T, or the default of T when the cast does not apply.

Type Parameters

T

The expected value type.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

operator ==(OlePropertyValue?, OlePropertyValue?)

public static bool operator ==(OlePropertyValue? left, OlePropertyValue? right)

Parameters

left OlePropertyValue
right OlePropertyValue

Returns

bool

operator !=(OlePropertyValue?, OlePropertyValue?)

public static bool operator !=(OlePropertyValue? left, OlePropertyValue? right)

Parameters

left OlePropertyValue
right OlePropertyValue

Returns

bool

Applies to

ProductVersions
.NET8, 10