Db4o marshaller implementation uses reflection to detect class fields. This approach is universal, but reflection usage imposes a certain performance penalty. In some cases you may want to improve the performance using custom marshallers through a plug-in interface:
c#:
Db4oFactory.Configure().ObjectClass(typeof(YourClass)).MarshallWith(yourMarshaller);
VB:
Db4oFactory.Configure().ObjectClass(GetType(YourClass)).MarshallWith(yourMarshaller)
Custom marshaller provides a functionality to convert object fields to a byte array and back. This approach allows to achieve a better performance due to the following:
However there are certain limitations:
Custom marshallers should implement an ObjectMarshaller interface:
c#:
public class CustomMarshaller: IObjectMarshaller
VB:
Class CustomMarshaller
Implements IObjectMarshaller
To simplify the task of creating custom marshallers db4o provides a PrimitiveCodec class, which implements write and read functions for int and long values.