/// <summary> /// Deserializes an object from the specified compact binary writer. /// </summary> /// <param name="writer">specified compact binary writer</param> /// <param name="graph">object</param> static internal object Deserialize(CompactBinaryReader reader) { // read type handle short handle = reader.ReadInt16(); // Find an appropriate surrogate by handle ISerializationSurrogate surrogate = TypeSurrogateProvider.GetSurrogateForTypeHandle(handle); return(surrogate.Read(reader)); }
/// <summary> /// Serializes an object into the specified compact binary writer. /// </summary> /// <param name="writer">specified compact binary writer</param> /// <param name="graph">object</param> static internal void Serialize(CompactBinaryWriter writer, object graph) { // Find an appropriate surrogate for the object ISerializationSurrogate surrogate = TypeSurrogateProvider.GetSurrogateForObject(graph); // write type handle writer.Write(surrogate.TypeHandle); surrogate.Write(writer, graph); }