MsgPack.Serialization.CollectionSerializers.NonGenericEnumerableMessagePackSerializerBase< TCollection > Class Template Referenceabstract

Provides basic features for non-dictionary non-generic collection serializers. More...

Inherits MsgPack.Serialization.MessagePackSerializer< TCollection >, and MsgPack.Serialization.CollectionSerializers.ICollectionInstanceFactory.

Inherited by MsgPack.Serialization.CollectionSerializers.NonGenericCollectionMessagePackSerializer< TCollection >, and MsgPack.Serialization.CollectionSerializers.NonGenericEnumerableMessagePackSerializer< TCollection >.

Protected Member Functions

 NonGenericEnumerableMessagePackSerializerBase (SerializationContext ownerContext, PolymorphismSchema schema)
 Initializes a new instance of the NonGenericEnumerableMessagePackSerializerBase<TCollection> class. More...
 
 NonGenericEnumerableMessagePackSerializerBase (SerializationContext ownerContext, PolymorphismSchema schema, SerializerCapabilities capabilities)
 Initializes a new instance of the NonGenericEnumerableMessagePackSerializerBase<TCollection> class. More...
 
abstract TCollection CreateInstance (int initialCapacity)
 Creates a new collection instance with specified initial capacity. More...
 
virtual void AddItem (TCollection collection, object item)
 When implemented by derive class, adds the deserialized item to the collection on TCollection specific manner to implement UnpackToCore(Unpacker,TCollection). More...
 

Additional Inherited Members

Detailed Description

Provides basic features for non-dictionary non-generic collection serializers.

Template Parameters
TCollectionThe type of the collection.

This class provides framework to implement variable collection serializer, and this type seals some virtual members to maximize future backward compatibility. If you cannot use this class, you can implement your own serializer which inherits MessagePackSerializer<T> and implements ICollectionInstanceFactory.

Type Constraints
TCollection :IEnumerable 

Constructor & Destructor Documentation

◆ NonGenericEnumerableMessagePackSerializerBase() [1/2]

Initializes a new instance of the NonGenericEnumerableMessagePackSerializerBase<TCollection> class.

Parameters
ownerContextA SerializationContext which owns this serializer.
schemaThe schema for collection itself or its items for the member this instance will be used to. null will be considered as PolymorphismSchema.Default.
Exceptions
ArgumentNullExceptionownerContext is null.

◆ NonGenericEnumerableMessagePackSerializerBase() [2/2]

Initializes a new instance of the NonGenericEnumerableMessagePackSerializerBase<TCollection> class.

Parameters
ownerContextA SerializationContext which owns this serializer.
schemaThe schema for collection itself or its items for the member this instance will be used to. null will be considered as PolymorphismSchema.Default.
capabilitiesA serializer calability flags represents capabilities of this instance.
Exceptions
ArgumentNullExceptionownerContext is null.

Member Function Documentation

◆ AddItem()

virtual void MsgPack.Serialization.CollectionSerializers.NonGenericEnumerableMessagePackSerializerBase< TCollection >.AddItem ( TCollection  collection,
object  item 
)
protectedvirtual

When implemented by derive class, adds the deserialized item to the collection on TCollection specific manner to implement UnpackToCore(Unpacker,TCollection).

Parameters
collectionThe collection to be added.
itemThe item to be added.
Exceptions
NotSupportedExceptionThis implementation always throws it.

◆ CreateInstance()

abstract TCollection MsgPack.Serialization.CollectionSerializers.NonGenericEnumerableMessagePackSerializerBase< TCollection >.CreateInstance ( int  initialCapacity)
protectedpure virtual

Creates a new collection instance with specified initial capacity.

Parameters
initialCapacityThe initial capacy of creating collection. Note that this parameter may 0 for non-empty collection.
Returns
New collection instance. This value will not be null.

An author of Unpacker could implement unpacker for non-MessagePack format, so implementer of this interface should not rely on that initialCapacity reflects actual items count. For example, JSON unpacker cannot supply collection items count efficiently.

See also
ICollectionInstanceFactory.CreateInstance

Implements MsgPack.Serialization.CollectionSerializers.ICollectionInstanceFactory.


The documentation for this class was generated from the following file:
  • MsgPackSources/Serialization/CollectionSerializers/NonGenericEnumerableMessagePackSerializerBase`1.cs