CustomPreference Class TIBCO Spotfire 7.6 API Reference
Extend this class to implement a set of preferences that are persisted locally and on the TIBCO Spotfire Analytics server.
Inheritance Hierarchy

SystemObject
  DedicatedThreadAccessible
    Spotfire.Dxp.Framework.PreferencesPreferenceBase
      Spotfire.Dxp.Application.ExtensionCustomPreference

Namespace: Spotfire.Dxp.Application.Extension
Assembly: Spotfire.Dxp.Application (in Spotfire.Dxp.Application.dll) Version: 25.11.10401.3615 (25.11.10401.3615)
Syntax

C#
public abstract class CustomPreference : PreferenceBase

The CustomPreference type exposes the following members.

Constructors

  NameDescription
Protected methodCustomPreference
Initializes a new instance of the CustomPreference class.
Top
Methods

  NameDescription
Protected methodAddPreferenceT
Call this method (in the constructor of your concrete preference class implementation) to add a new property to your preference class.
(Inherited from PreferenceBase.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnPropertyChanged
Override this method to perform desired operations when a the value of a property has changed.
(Inherited from PreferenceBase.)
Public methodReset
Resets all values that may explicitly have been given to the properties of this preference on a user level basis through a calls to Value. The effect of resetting a property is that when the Value of it is queried, either the group value or the default value will be returned.
(Inherited from PreferenceBase.)
Public methodSave
Persists all changes to the properties of this preference object.
(Inherited from PreferenceBase.)
Public methodUndoChanges
Undoes any changes that may have been to all of the properties of this preference, since it was last saved.
(Inherited from PreferenceBase.)
Top
Properties

  NameDescription
Public propertyCategory
Implementations of this property are to return the name of the category to which the preference belongs. The category name must not be null or an empty string for the preference to be properly persisted.
(Inherited from PreferenceBase.)
Public propertyIsEmpty
Gets a value indicating whether this preference object only contains default property values or not.
(Inherited from PreferenceBase.)
Public propertySubCategory
Implementations of this property are to return the name of the subcategory to which the preference belongs. The subcategory must not be null or an empty string for the preference to be properly persisted.
(Inherited from PreferenceBase.)
Top
Events

  NameDescription
Public eventPropertyChanged
Occurs when one of the properties in this preference is changed.
(Inherited from PreferenceBase.)
Top
Remarks

Preferences are used by add-ins to persist one or more values, for example last used settings, user preferred values, etc. An object of this type can contain one or more such values, referred to as Preference Properties. Thus to create a set of preference properties, extend this class and populate that class with the properties that shall be persisted.

When a user is logged on, the preference is populated with its persisted values, if such exist. If not, the preference is given default values while waiting for the user to set its values. When preferences are saved, their values are persisted using .Net serialization on the client and on the server depending on the settings of the preference.

Preferences properties can be applied to single users or to user groups. Preferences applied to a group are inherited by all members of the group. The users can, however, choose to override the properties with custom values. In the same way, a group can override the properties inherited from its parent groups. If the group has more than one parent group, the value from the Primary parent group (as defined using the TIBCO Spotfire Administration Manager).

It is important for your preference implementation class to be decorated with the PersistenceVersionAttribute. If it is not, it will not be possible to register the preference class with the preference framework.

Examples

The following example shows an implementation of a preference class that stores two preferences of types string and ArrayList of integers.
C#
[Spotfire.Dxp.Framework.Persistence.PersistenceVersion(1, 0)]
public class MyPreference : CustomPreference
{
    private PreferenceProperty<string> myString; // Defaults to null
    private PreferenceProperty<ArrayList> numberList;

    public override string Category
    {
        get { return "MyCategory"; }
    }

    public override string SubCategory
    {
        get { return "MySubCategory"; }
    }

    public void AddToList(int value)
    {
        this.numberList.Value.Add(value);
        // Notify the framework of changes
        this.numberList.OnValueChanged();
    }

    public string MyString
    {
        get { return this.myString.Value; }
        set
        {
            // The framwork is aware of the change to the property since
            // it is explicitly set.
            this.myString.Value = value;
        }
    }

    public MyPreference()
    {
        this.myString = this.AddPreference<string>(
            new PreferenceProperty<string>(
            "myString", "1.0",
            PreferencePersistenceScope.Server,
            PreferenceUsage.SingleUser));

        this.numberList = this.AddPreference<ArrayList>(
            new PreferenceProperty<ArrayList>(
                "numberList", "1.0",
                PreferencePersistenceScope.Server,
                PreferenceUsage.SingleUser,
                delegate
                {
                    // Calculate the default value
                    ArrayList defaultList = new ArrayList();
                    defaultList.Add(10);
                    return defaultList;
                }));
    }
}
Version Information

Supported in: 7.6, 7.5, 7.0, 6.5, 6.0, 5.5, 5.0
See Also

Reference