GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer Class Reference

Inherits GemStone::GemFire::Cache::Generic::IPdxSerializer.


Detailed Description

This class uses .NET reflection in conjunction with IPdxSerializer to perform automatic serialization of domain objects. The implication is that the domain classes do not need to implement the interface. This implementation will serialize all relevant fields. This will not serialize the fields which has defined attribute NonSerialized. This will not serialize the static, literal and readonly fields. Use to define member field as identity field. Identity fields are used for hashcode creation and equals methods.

Public Member Functions

virtual Object^ CreateObject (String^ className)
virtual Object^ FromData (String^ o, IPdxReader^ reader)
virtual String^ GetFieldName (FieldInfo^ fi, Type^ type)
virtual FieldType GetFieldType (FieldInfo^ fi, Type^ type)
virtual bool IsFieldIncluded (FieldInfo^ fi, Type^ type)
virtual bool IsIdentityField (FieldInfo^ fi, Type^ type)
virtual Object^ ReadTransform (FieldInfo^ fi, Type^ type, Object^ serializeValue)
virtual bool ToData (Object^ o, IPdxWriter^ writer)
virtual Object^ WriteTransform (FieldInfo^ fi, Type^ type, Object^ originalValue)

Member Function Documentation

virtual Object ^ GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::CreateObject ( String^   className  )  [virtual]

Overirde this method to create default instance of className Otherwise it will create instance using zer arg public constructor

Parameters:
className name of the class to create default instance
Returns:
the defaulf instance

virtual Object ^ GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::FromData ( String^   classname,
IPdxReader^   reader 
) [virtual]

Deserialize this object.

Parameters:
classname the classname whose object need to de-serialize
reader the IPdxReader stream to use for reading the object data

Implements GemStone::GemFire::Cache::Generic::IPdxSerializer.

virtual String ^ GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::GetFieldName ( FieldInfo^   fi,
Type^   type 
) [virtual]

Controls the field name that will be used in pdx for a field being auto serialized. Override this method to customize the field names that will be generated by auto serialization. It allows you to convert a local, language dependent name, to a more portable name. The returned name is the one that will show up in a IPdxInstance and that one that will need to be used to access the field when doing a query.

The default implementation returns the name obtained from fi.

This method is only called the first time it sees a new class. The result will be remembered and used the next time the same class is seen.

Parameters:
fi the field whose name is returned.
<param name"type"> type the original class being serialized that owns this field.

Returns:
the name of the field

virtual FieldType GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::GetFieldType ( FieldInfo^   fi,
Type^   type 
) [virtual]

Controls what pdx field type will be used when auto serializing. Override this method to customize what pdx field type will be used for a given domain class field.

The default implementation uses type of field.

This method is only called the first time it sees a new class. The result will be remembered and used the next time the same class is seen.

Parameters:
fi the field whose pdx field type needs to be determined
type the original class being serialized that owns this field.
Returns:
the pdx field type of the given domain class field.

virtual bool GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::IsFieldIncluded ( FieldInfo^   fi,
Type^   type 
) [virtual]

Controls what fields of a class will be auto serialized by this serializer. Override this method to customize what fields of a class will be auto serialized. The default implementation:

All other fields are included. This method is only called the first time it sees a new class. The result will be remembered and used the next time the same class is seen.

Parameters:
fi the field being considered for serialization
type the original class being serialized that owns this field.
Returns:
true if the field should be serialized as a pdx field; false if it should be ignored.

virtual bool GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::IsIdentityField ( FieldInfo^   fi,
Type^   type 
) [virtual]

Controls what fields of a class that is auto serialized will be marked as pdx identity fields. Override this method to customize what fields of an auto serialized class will be identity fields. Identity fields are used when a IPdxInstance computes its hash code and checks to see if it is equal to another object.

The default implementation only marks fields that match an "#identity=" pattern as identity fields.

This method is only called the first time it sees a new class. The result will be remembered and used the next time the same class is seen.

Parameters:
fi the field to test to see if it is an identity field.
type the original class being serialized that owns this field.
Returns:
true if the field should be marked as an identity field; false if not.

virtual Object ^ GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::ReadTransform ( FieldInfo^   fi,
Type^   type,
Object^   serializeValue 
) [virtual]

Controls what field value is read during auto deserialization. Override this method to customize the data that will be read during auto deserialization. This method will only be called if transformFieldValue returned true.

Parameters:
fi the field in question
type the original class being serialized that owns this field. Note that this field may have been inherited from a super class by this class.
the value of the field that was serialized for this field.

Returns:
the actual value to write for this field. Return serializedValue if you decide not to transform the value.

virtual bool GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::ToData ( Object^   o,
IPdxWriter^   writer 
) [virtual]

Serializes this object in gemfire PDX format.

Parameters:
o the object which need to serialize
writer the IPdxWriter object to use for serializing the object

Implements GemStone::GemFire::Cache::Generic::IPdxSerializer.

virtual Object ^ GemStone::GemFire::Cache::Generic::ReflectionBasedAutoSerializer::WriteTransform ( FieldInfo^   fi,
Type^   type,
Object^   originalValue 
) [virtual]

Controls what field value is written during auto serialization. Override this method to customize the data that will be written during auto serialization.

Parameters:
fi the field in question
type the original class being serialized that owns this field.
originalValue the value of the field that was read from the domain object.
Returns:
the actual value to write for this field. Return originalValue if you decide not to transform the value.


GemFire C++ Cache .NET API Documentation