As a transitional step, this site will temporarily be made Read-Only from July 8th until the new community launch. During this time, you can still search and read articles and discussions.

While the community is read-only, if you have questions or issues requiring TIBCO review/response, please access the new TIBCO Community and select "Ask A Question."

You will need to register or log in or register to engage in the new community.

Using Readonly Properties with the TIBCO Spotfire® Document Model Framework API

Last updated:
6:01am Jan 20, 2017

Overview

This page describes how to use readonly properties with the TIBCO Spotfire® Document Model Framework API.

Some properties stored in ordinary readonly fields never change after initialization. They nevertheless must be initialized in a special way for the Document Model Framework to keep track of them.

Some properties of a node are never changed. For example, the node that represents the root of the document holds a reference to the data manager and to a collection of pages. Such properties are stored in ordinary read only fields but the document model framework needs to know of them. Thus such fields must be initialized in a special way.

Consider a node that represents a page. It holds a reference to a collection of visualizations. Such properties typically contain other document nodes which are then owned by the node. In those cases the document model framework needs to know of them in order to manage ownership. The pattern is as follows.

Implementation Pattern

public class Example : DocumentNode
{
    public new class PropertyNames : DocumentNode.PropertyNames
    {
        public static readonly PropertyName ChildNode = CreatePropertyName("ChildNode");
    }
 
    private readonly SomeNode childNode;
 
    public SomeNode ChildNode
    {
        get { return this.childNode; }
    }
 
    public Example(SomeNode someNode)
    {
        CreateReadOnlyProperty(
           PropertyNames.ChildNode,
           someNode,
           out this.childNode);
    }
 
    internal Example(SerializationInfo info, StreamingContext context) : base(info, context)
    {
        DeserializeReadOnlyProperty(
           info,
           context,
           PropertyNames.ChildNode,
           out this.childNode);
    }
 
    protected override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        base.GetObjectData(info, context);
 
        SerializeReadOnlyProperty(
           info,
           context,
           PropertyNames.ChildNode,
           this.childNode);
    }
}