Spotfire.Dxp.Framework.DocumentModelRuntimePropertyT
Namespace: Spotfire.Dxp.Framework.DocumentModel
Assembly: Spotfire.Dxp.Framework (in Spotfire.Dxp.Framework.dll) Version: 64.0.19329.3263 (64.0.19329.3263)
public sealed class RuntimeProperty<T>
Type Parameters
- T
- The Type of the values held by the runtime property. This must be an immutable type.
The RuntimePropertyT type exposes the following members.
Name | Description | |
---|---|---|
Value |
Returns the cached value of the property, or computes it if no cached value exists.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
A RuntimeProperty can be thought of as internally having two states, Invalid and Valid: Invalid This is the initial state. The RuntimeProperty has no value. The PropertyComputerT will be invoked to compute the value when the Value property is accessed and this will set the RuntimeProperty in state Valid. The RuntimeProperty does not generate any event when a property that it depends upon, as defined by the StatelessDependencyDeclarer, is changed. Valid The RuntimeProperty has a cached value which is returned when the Value property is accessed. When a property that the RuntimeProperty depends upon, as defined by the StatelessDependencyDeclarer, is changed, an event is generated, the value is dropped and the RuntimeProperty is set in state Invalid.
To use RuntimeProperties in a class deriving from DocumentNode, follow this pattern:
- Declare a private readonly RuntimeProperty<TValue> field for each RuntimeProperty, where TValue is the type of the value in the RuntimeProperty. Note that this must be an immutable value.
- Declare a method private void InitRuntimeProperties(out RuntimeProperty<TValue> myRtp, ...) that has one out parameter for each RuntimeProperty. This method shall call DocumentNode.CreateRuntimeProperty to create a RuntimeProperty object and assign the out parameters.
- Call the InitRuntimeProperties at the end of each constructor, including the deserialization constructor.