MessagePackRuntimeCollectionItemTypeAttribute Class |
Marks that the runtime type of items/values of this collection/dictionary should be encoded with type information for polymorphism.
Inheritance Hierarchy
Namespace: MsgPack.SerializationAssembly: MsgPack (in MsgPack.dll) Version: 0.6.0
Syntax [AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)]
public sealed class MessagePackRuntimeCollectionItemTypeAttribute : Attribute
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field)>
Public NotInheritable Class MessagePackRuntimeCollectionItemTypeAttribute
Inherits Attribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field)]
public ref class MessagePackRuntimeCollectionItemTypeAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)>]
type MessagePackRuntimeCollectionItemTypeAttribute =
class
inherit Attribute
end
The MessagePackRuntimeCollectionItemTypeAttribute type exposes the following members.
Constructors Remarks
When you apply this attribute to a member, the items/values of the collection/dictionary will be serialized with .NET specific type information,
so deserializer will be able to deserialize object which is actual type when serialized instead of interoperability.
Because non-.NET enviroments (Java, Ruby, Go, etc.) cannot interpret .NET native type identifier,
you should not use this attribute when the serialized stream will be possible to be used from non-.NET environment.
The typed object will be encoded as 2 elements array as follows, so your deserializer can skip type information as needed:
[ <type-info>, <actual-value (array or map)>]
In this point, type-info will be encoded as compressed assembly qualified name as follows:
[ <compressed type full name>, <assembly simple name>, <version binary>, <culture string>, <public key token binary>]
If the type full name starts with its assembly simple name, then the prefix matched to assembly simple name will be omitted
(as a result, compressed type name starts with dot).
Note |
---|
You should use this attribute CAREFULLY when you deserialize data from outside, because this feature can inject arbitary process in your code through
constructor and some virtual methods if exist.
It is highly recommended avoid using Object type as member's declaring type,
you should specify your base class which and derived typed are fully controled under your organization instead.
It mitigate chance of potential exploits.
|
See Also