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
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
Methods
AsBoolean()
Returns the value as a boolean when it is a boolean scalar.
public bool? AsBoolean()
Returns
AsBytes()
Returns the value as a byte array when it is a blob or clipboard scalar.
public byte[]? AsBytes()
Returns
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
AsInt64()
Returns the value as a 64-bit integer when it is an integral scalar.
public long? AsInt64()
Returns
AsString()
Returns the value as a string when it is a string scalar.
public string? AsString()
Returns
AsTimeSpan()
Returns the value as an elapsed duration when it is a FILETIME scalar.
public TimeSpan? AsTimeSpan()
Returns
Create(bool)
Creates a boolean property value.
public static OlePropertyValue Create(bool value)
Parameters
valueboolThe 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
valueDateTimeOffsetThe 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
valuedoubleThe floating-point value.
Returns
- OlePropertyValue
A new OlePropertyValue.
Create(short)
Creates a 16-bit integer property value.
public static OlePropertyValue Create(short value)
Parameters
valueshortThe integer value.
Returns
- OlePropertyValue
A new OlePropertyValue.
Create(int)
Creates a 32-bit integer property value.
public static OlePropertyValue Create(int value)
Parameters
valueintThe integer value.
Returns
- OlePropertyValue
A new OlePropertyValue.
Create(long)
Creates a 64-bit integer property value.
public static OlePropertyValue Create(long value)
Parameters
valuelongThe 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
valuestringThe string value.
typeOlePropertyTypeThe string property type; defaults to AnsiString.
Returns
- OlePropertyValue
A new OlePropertyValue.
Exceptions
- ArgumentNullException
Thrown when
valueis null.
CreateBlob(byte[])
Creates a blob property value.
public static OlePropertyValue CreateBlob(byte[] value)
Parameters
valuebyte[]The blob bytes.
Returns
- OlePropertyValue
A new OlePropertyValue.
Exceptions
- ArgumentNullException
Thrown when
valueis null.
Equals(OlePropertyValue?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(OlePropertyValue? other)
Parameters
otherOlePropertyValueAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
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 ofTwhen the cast does not apply.
Type Parameters
TThe 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
leftOlePropertyValuerightOlePropertyValue
Returns
operator !=(OlePropertyValue?, OlePropertyValue?)
public static bool operator !=(OlePropertyValue? left, OlePropertyValue? right)
Parameters
leftOlePropertyValuerightOlePropertyValue
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |