MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializerBase< TDictionary, TKey, TValue > Class Template Referenceabstract

Provides common features for generic dictionary serializers. More...

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

Inherited by MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializer< TDictionary, TKey, TValue >.

Protected Member Functions

 DictionaryMessagePackSerializerBase (SerializationContext ownerContext, PolymorphismSchema schema)
 Initializes a new instance of the DictionaryMessagePackSerializerBase<TDictionary, TKey, TValue> class. More...
 
 DictionaryMessagePackSerializerBase (SerializationContext ownerContext, PolymorphismSchema schema, SerializerCapabilities capabilities)
 Initializes a new instance of the DictionaryMessagePackSerializerBase<TDictionary, TKey, TValue> class. More...
 
abstract int GetCount (TDictionary dictionary)
 When overridden in derived class, returns count of the dictionary. More...
 
abstract TDictionary CreateInstance (int initialCapacity)
 Creates a new collection instance with specified initial capacity. More...
 
virtual void AddItem (TDictionary dictionary, TKey key, TValue value)
 When implemented by derive class, adds the deserialized item to the collection on TDictionary specific manner to implement UnpackToCore(Unpacker,TDictionary). More...
 

Additional Inherited Members

Detailed Description

Provides common features for generic dictionary serializers.

Template Parameters
TDictionaryThe type of the dictionary.
TKeyThe type of the key of dictionary.
TValueThe type of the value of dictionary.

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
TDictionary :IEnumerable 
TDictionary :KeyValuePair 
TDictionary :TKey 
TDictionary :TValue 

Constructor & Destructor Documentation

◆ DictionaryMessagePackSerializerBase() [1/2]

Initializes a new instance of the DictionaryMessagePackSerializerBase<TDictionary, TKey, TValue> 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.

◆ DictionaryMessagePackSerializerBase() [2/2]

Initializes a new instance of the DictionaryMessagePackSerializerBase<TDictionary, TKey, TValue> 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.DictionaryMessagePackSerializerBase< TDictionary, TKey, TValue >.AddItem ( TDictionary  dictionary,
TKey  key,
TValue  value 
)
protectedvirtual

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

Parameters
dictionaryThe dictionary to be added.
keyThe key to be added.
valueThe value to be added.
Exceptions
NotSupportedExceptionThis implementation always throws it.

Reimplemented in MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializer< TDictionary, TKey, TValue >.

◆ CreateInstance()

abstract TDictionary MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializerBase< TDictionary, TKey, TValue >.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.

◆ GetCount()

abstract int MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializerBase< TDictionary, TKey, TValue >.GetCount ( TDictionary  dictionary)
protectedpure virtual

When overridden in derived class, returns count of the dictionary.

Parameters
dictionaryA collection. This value will not be null.
Returns
The count of the dictionary .

Implemented in MsgPack.Serialization.CollectionSerializers.DictionaryMessagePackSerializer< TDictionary, TKey, TValue >.


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