PreferenceObjectT Class

Spotfire 14.2 API Reference
A preference object is a named value that can be stored on a user, group, and global level. Preference objects are managed through the PreferenceObjectService, using which new objects can be added, removed, and queried. The addition and removal of objects is, however, only available on a user (personal) level. Adding preference object to one or more groups is only available through the user interface of the application itself.

A preference object consists of a unique identification (a name) within its preference object class (see below), and the actual value. This means that two different users cannot create an object with the same name within the same preference object class.

The value type of a preference object is generic to reflect the type of the preference class it belongs to. To be able to persist preference objects, the value type must be serializable. In addition, it is also recommended for the type to be immutable, that is, it should not be possible to change the state of objects of that type through public property setters or methods.

Once added to the PreferenceObjectService, preference objects are fully managed by that service and synchronized with the server. If the Value of the preference object changes, the ValueChanged event is fired with a PreferenceObjectValueChangedEventArgsT containing the previous and the new value. Through this event, the PreferenceObjectService can track changes and reflect them both locally and on the server. However, if the value type of the object is not immutable and its internal state changes, the event is not fired and the changes will not be detected by the manager. In such cases, it is absolutely necessary to explicitly requested for the changes to be persisted through a call to ApplyChangesT(PreferenceObjectT).

In some cases it is not possible to alter the value of a preference object. Whether or not the value of an object can be changed is reflected through the IsReadOnly property. Objects that are inherited from the group or those that are global are examples of read-only objects.

A group of (that is, one or more) preference objects belong to one preference class. One such class is globally identified through its name (a string), for example MyPreferenceObjects or Spotfire.Dxp.PreferenceObjects. Note that a preference class does not physically exist either locally or on the server. They are comparable to the concept of namespaces in .Net programming languages. All preference objects belonging to the same preference class must have the same value type T. This implies that classes should be logically named to hold preference objects for a well defined area.

It is possible to define default preference objects at group and application level. Such default objects are used as fallback objects, for example when searching a class (see FindT(String, T, PreferenceObjectIdentifier)).

Inheritance Hierarchy

SystemObject
  DedicatedThreadAccessible
    Spotfire.Dxp.Framework.PreferencesPreferenceObjectT

Namespace:  Spotfire.Dxp.Framework.Preferences
Assembly:  Spotfire.Dxp.Framework (in Spotfire.Dxp.Framework.dll) Version: 64.0.19329.3263 (64.0.19329.3263)
Syntax

C#
[SerializableAttribute]
[PersistenceVersionAttribute(1, 0)]
public sealed class PreferenceObject<T> : DedicatedThreadAccessible

Type Parameters

T
The type of the value that the preference object is to contain. The type must be serializable. In addition, it is recommended for the type to implement the Equals(Object) and to be immutable.

The PreferenceObjectT type exposes the following members.

Constructors

  NameDescription
Public methodPreferenceObjectT
Creates a new instance of type PreferenceObjectT given value.
Top
Properties

  NameDescription
Public propertyId
Gets the Identifier for this preference object.
Public propertyIsApplicationDefault
Gets if this object is the default object defined for the class.
Public propertyIsDefault
Gets if this is the default object for the class at group level.
Public propertyIsReadOnly
Gets whether or not this object is read only, that is, if its value can be changed by the user.
Public propertyValue
Gets or sets the value for this preference object. If the object is read only, a NotSupportedException will be thrown if trying to set the value. When the value is set the ValueChanged event will be fired.
Top
Methods

  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events

  NameDescription
Public eventValueChanged
Occurs when the value of this object is changed.
Top
Version Information

Supported in: 14.2, 14.1, 14.0, 12.5, 12.4, 12.3, 12.2, 12.1, 12.0, 11.8, 11.7, 11.6, 11.5, 11.4
See Also

Reference