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)).
DedicatedThreadAccessible
Spotfire.Dxp.Framework.PreferencesPreferenceObjectT
Namespace: Spotfire.Dxp.Framework.Preferences
Assembly: Spotfire.Dxp.Framework (in Spotfire.Dxp.Framework.dll) Version: 66.0.19621.1485 (66.0.19621.1485)
[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.
Name | Description | |
---|---|---|
![]() | PreferenceObjectT | Creates a new instance of type
PreferenceObjectT given value.
|
Name | Description | |
---|---|---|
![]() | Id | Gets the Identifier for this preference object.
|
![]() | IsApplicationDefault | Gets if this object is the default object defined for
the class.
|
![]() | IsDefault | Gets if this is the default object for the class at group level.
|
![]() | IsReadOnly | Gets whether or not this object is read only,
that is, if its value can be changed by the user.
|
![]() | Value | 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.
|
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.) |
Name | Description | |
---|---|---|
![]() | ValueChanged | Occurs when the value of this object is changed.
|