Configuring which serializer is used

This page explains how you can configure which serializer is used, either by config string or by fluent interface.
Currently the following serializers are available:
  • Binary Serializer (XcoBinarySerializer): This is the default serializer. It internally uses the BinaryFormatter class, which allows to serialize nearly all class structures. The only precondition is that all message classes need to be marked with the Serializable Attribute.
  • Json Serializer (XcoJsonSerializer): This is the serializer for communication with compact framework and silverlight. It does not require marking classes with any special attributes, but simply serializes all public properties that have a getter and setter. The only requirement is that classes need to be public. Compared to the binary serializer messages are significantly smaller, so this serializer may also be a good choice when you have a scenario with low bandwidth.
The serializers actually don't have any configurable properties themselves, but you can configure which serializer is used like this:

Config String

With the config string the following option can be configured:
  • serializer: Configures which serializer is used. Currently the allowed values are binary and json.
Here is an example:
var space = new XcoAppSpace("tcp.port=9000;serializer=json");

Fluent Inferface

With the fluent interface you can use the UsingService method for defining which serializer to use, and additionally you can define a name for the serializer:
  • WithName(string name): Configures the name of the serializer. A name should be assigned if the space instance uses multiple transport services, and for each transport service a different serializer is needed (you can then use the WithSerializer fluent method to define which transport service uses which serializer) .
Here is an example for a config with two transport service, where each uses a different serializer:
XcoAppSpace space = XcoAppSpace.Configure

Last edited Dec 21, 2012 at 1:19 PM by thomass, version 1


No comments yet.