AddInPersistenceManagerRegistrarAddTypeBinding Method

Spotfire 14.2 API Reference
Adds a binding of a type with the specified original assembly and type name. Use this method to add support for backwards compatibility with respect to removed types. When an object with the specified specified original assembly and type, marked with a PersistenceVersion attribute less than the specified majorUpperVersion and minorUpperVersion, is encountered in the serialized format, an object of the specified boundType will be deserialized in place of the original type.

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

C#
public void AddTypeBinding(
	string originalAssemblyName,
	string originalTypeName,
	int majorUpperVersion,
	int minorUpperVersion,
	Type boundType
)

Parameters

originalAssemblyName
Type: SystemString
Name of the original assembly.
originalTypeName
Type: SystemString
Name of the original type.
majorUpperVersion
Type: SystemInt32
Used with minorVersion to specify when this binding shall apply.
minorUpperVersion
Type: SystemInt32
The smallest minor version (within the specified majorVersion) of the specified original type for which this binding shall not apply.
boundType
Type: SystemType
The type that is to be bound to the specified original type.
Examples

Assume that type A is no longer available and has been replaced by type B. Also assume that the last PersistenceVersion of A was 1.7. To deserialize a document containing objects of type A as objects of type B, a call to PersistenceManager.AddTypeBinding() must be made. Typically, the call shall be made by an AddIn related to A and B.
persistenceManager.AddTypeBinding(
        "The.Assembly.Name.Of.Type.A, Version=1.0.0.0, PublicKeyToken=094358714857...", 
        "Some.Namespace.A", 
        1, 8, typeof(B));
With the binding above, all occurences of type A in the serialized document will be replaced with type B, including uses as array element type and generic arguments. Thus a serialized List<A> will deserialize as a List<B>.

It is also possible to add bindings for generic types. Assume that the type Foo<T> is no longer available and has been replaced by type Bar<T>. Also assume that the last PersistenceVersion of Foo<T> was 1.0. To deserialize a document containing objects of type Foo<int>, Foo<string>, etc., as objects of type Bar<int> and Bar<string>, a call to PersistenceManager.AddTypeBinding() must be made as follows:

persistenceManager.AddTypeBinding(
        "The.Assembly.Name.Of.Type.Foo, Version=1.0.0.0, PublicKeyToken=094358714857...", 
        "Some.Namespace.Foo`1",  // The "`1" syntax means "Generic type with one type argument". 
        1, 1, typeof(Bar<>));

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