2.2.5.2.3 Type Names

Serialization of Complex Objects can include a list of type names (see section 2.2.5.3.4.5). Serialization MUST preserve the information provided by the higher layer about type names of an object. As specified in section 2.2.5.3.4.5, an object might not provide any type names at all, in which case the <TN> and <TNRef> elements MUST be omitted.

If the type information has been already serialized earlier in the same instance of the serializer, this information can be referenced using the <TNRef> element with the RefId attribute set to the identity of the earlier result of serializing type information. If type information has not been serialized earlier, a <TN> element is written.

The <TN> element contains <T> elements, each of which contains the name of a type associated with the object being serialized. <T> elements MUST be ordered from the most specific (that is, point) to least specific (that is, object). Type names MUST be encoded as described in section 2.2.5.3.2. Mapping type names to concrete types is outside the scope of the protocol and is an implementation detail.

The <TN> element always has a RefId attribute which identifies the type information; the <TN> element can be referenced later by <TNRef> elements. The type identifier used MUST be unique during the lifetime of a serializer/deserializer pair (see section 2.2.5.3.3 for details). The identifier can be any string that is valid in an XML attribute.

Example:

 <Obj><LST>
   <Obj RefId="RefId-0">
     <TN RefId="RefId-0">
       <T>System.Drawing.Point</T>
       <T>System.ValueType</T>
       <T>System.Object</T>
     </TN>
     <ToString>{X=12,Y=34}</ToString>
     <Props>
       <B N="IsEmpty">false</B>
       <I32 N="X">12</I32>
       <I32 N="Y">34</I32>
     </Props>
   </Obj>
   <Obj RefId="RefId-1">
     <TNRef RefId="RefId-0" />
     <ToString>{X=56,Y=78}</ToString>
     <Props>
       <B N="IsEmpty">false</B>
       <I32 N="X">56</I32>
       <I32 N="Y">78</I32>
     </Props>
   </Obj>
 </LST></Obj>