/// <summary>
 /// Registers a custom serialization and deserialization pair for a object.
 /// This is useful for writing objects that are behind the third party wall. Such as .NET types.
 /// </summary>
 /// <param name="onSerialize">The delegate to invoke to serialize the type.</param>
 /// <param name="onDeserialize">The delegate to invoke to deserialize the type.</param>
 /// <typeparam name="T">The type to register.</typeparam>
 public static void RegisterSerializationHandlers <T>(CustomSerializationDelegate <T> onSerialize, CustomDeserializationDelegate <T> onDeserialize)
 {
     cachedExternalSerializers[typeof(T)]   = delegate(Stream stream, object instance) { onSerialize(stream, (T)instance); };
     cachedExternalDeserializers[typeof(T)] = delegate(Stream stream) { return(onDeserialize(stream)); };
 }
Esempio n. 2
0
 /// <summary>
 /// Registers a custom serialization and deserialization pair for a object.
 /// This is useful for writing objects that are behind the third party wall. Such as .NET types.
 /// </summary>
 /// <param name="onSerialize">The delegate to invoke to serialize the type.</param>
 /// <param name="onDeserialize">The delegate to invoke to deserialize the type.</param>
 /// <typeparam name="T">The type to register.</typeparam>
 public static void RegisterSerializationHandlers <T>(CustomSerializationDelegate <T> onSerialize, CustomDeserializationDelegate <T> onDeserialize)
 {
     s_CachedExternalSerializers[typeof(T)]   = (stream, instance) => onSerialize(stream, (T)instance);
     s_CachedExternalDeserializers[typeof(T)] = stream => onDeserialize(stream);
 }