Class PofAnnotationSerializer
A PofAnnotationSerializer provides annotation based de/serialization.
Implements
Inherited Members
Namespace: Tangosol.IO.Pof
Assembly: Coherence.dll
Syntax
public class PofAnnotationSerializer : IPofSerializer
Remarks
This serializer must be instantiated with the intended class which is eventually scanned for the presence of the following annotations.
This serializer supports classes iff they are annotated with the type level annotation; Portable. This annotation is a marker annotation with no children. All fields annotated with PortableProperty are explicitly deemed POF serializable with the option of specifying overrides to provide explicit behaviour such as:- Explicit POF indexes
- Custom ICodec to specify concrete implementations / customizations
autoIndex
constructor
argument. This feature determines the index based on any explicit
indexes specified and the name of the portable properties. Currently
objects with multiple versions is not supported. The following
illustrates the auto index algorithm:
Name | Explicit Index | Determined Index |
c | 1 | 1 |
a | 0 | |
b | 2 |
Constructors
PofAnnotationSerializer(int, Type)
Constructs a PofAnnotationSerializer.
Declaration
public PofAnnotationSerializer(int typeId, Type type)
Parameters
Type | Name | Description |
---|---|---|
int | typeId | The POF type id. |
Type | type | Type this serializer is aware of. |
PofAnnotationSerializer(int, Type, bool)
Constructs a PofAnnotationSerializer.
Declaration
public PofAnnotationSerializer(int typeId, Type type, bool autoIndex)
Parameters
Type | Name | Description |
---|---|---|
int | typeId | The POF type id. |
Type | type | Type this serializer is aware of. |
bool | autoIndex | Turns on the auto index feature. |
Methods
Deserialize(IPofReader)
Deserialize a user type instance from a POF stream by reading its state using the specified IPofReader object.
Declaration
public virtual object Deserialize(IPofReader reader)
Parameters
Type | Name | Description |
---|---|---|
IPofReader | reader | The IPofReader with which to read the object's state. |
Returns
Type | Description |
---|---|
object | The deserialized user type instance. |
Remarks
An implementation of IPofSerializer is required to follow the following steps in sequence for reading in an object of a user type:
- If the object is evolvable, the implementation must get the version by calling VersionId.
- The implementation may read any combination of the properties of the user type by using "read" methods of the IPofReader, but it must do so in the order of the property indexes.
- After all desired properties of the user type have been read, the implementation must terminate the reading of the user type by calling ReadRemainder().
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |
Serialize(IPofWriter, object)
Serialize a user type instance to a POF stream by writing its state using the specified IPofWriter object.
Declaration
public virtual void Serialize(IPofWriter writer, object o)
Parameters
Type | Name | Description |
---|---|---|
IPofWriter | writer | The IPofWriter with which to write the object's state. |
object | o | The object to serialize. |
Remarks
An implementation of IPofSerializer is required to follow the following steps in sequence for writing out an object of a user type:
- If the object is evolvable, the implementation must set the version by calling VersionId.
- The implementation may write any combination of the properties of the user type by using the "write" methods of the IPofWriter, but it must do so in the order of the property indexes.
- After all desired properties of the user type have been written, the implementation must terminate the writing of the user type by calling WriteRemainder(Binary).
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |