protected void InvokeOnDeserializingCallbacks(T value, DeserializationContext context) { this.InvokeOnDeserializingCallbacks(ref value, context); }
/// <summary> /// Deserializes a value of a given type from the given byte array in the given format, using the given list of Unity objects for external index reference resolution. /// </summary> /// <typeparam name="T">The type to deserialize.</typeparam> /// <param name="bytes">The bytes to deserialize from.</param> /// <param name="format">The format to read.</param> /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param> /// <param name="context">The context to use.</param> /// <returns> /// The deserialized value. /// </returns> public static T DeserializeValue <T>(byte[] bytes, DataFormat format, List <UnityEngine.Object> referencedUnityObjects, DeserializationContext context = null) { using (var stream = CachedMemoryStream.Claim(bytes)) { return(DeserializeValue <T>(stream.Value.MemoryStream, format, referencedUnityObjects, context)); } }
/// <summary> /// Deserializes a value of a given type from the given byte array in the given format, using the given list of Unity objects for external index reference resolution. /// </summary> /// <typeparam name="T">The type to deserialize.</typeparam> /// <param name="bytes">The bytes to deserialize from.</param> /// <param name="format">The format to read.</param> /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param> /// <param name="context">The context to use.</param> /// <returns> /// The deserialized value. /// </returns> public static T DeserializeValue <T>(byte[] bytes, DataFormat format, List <UnityEngine.Object> referencedUnityObjects, DeserializationContext context = null) { using (MemoryStream stream = new MemoryStream(bytes)) // TODO: Cache and reuse memory streams? { return(DeserializeValue <T>(stream, format, referencedUnityObjects, context)); } }
/// <summary> /// Deserializes a value of a given type from the given stream in the given format, using the given list of Unity objects for external index reference resolution. /// </summary> /// <typeparam name="T">The type to deserialize.</typeparam> /// <param name="stream">The stream to read from.</param> /// <param name="format">The format to read.</param> /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param> /// <param name="context">The context.</param> /// <returns> /// The deserialized value. /// </returns> public static T DeserializeValue <T>(Stream stream, DataFormat format, List <UnityEngine.Object> referencedUnityObjects, DeserializationContext context = null) { var reader = GetCachedReader(stream, context, format); try { if (context != null) { return(DeserializeValue <T>(reader, referencedUnityObjects)); } else { using (var con = Cache <DeserializationContext> .Claim()) { reader.Context = con; return(DeserializeValue <T>(reader, referencedUnityObjects)); } } } finally { FreeCachedReader(reader); } }
/// <summary> /// Deserializes a value of a given type from the given stream in the given format, using the given list of Unity objects for external index reference resolution. /// </summary> /// <typeparam name="T">The type to deserialize.</typeparam> /// <param name="stream">The stream to read from.</param> /// <param name="format">The format to read.</param> /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param> /// <param name="context">The context.</param> /// <returns> /// The deserialized value. /// </returns> public static T DeserializeValue <T>(Stream stream, DataFormat format, List <UnityEngine.Object> referencedUnityObjects, DeserializationContext context = null) { if (context != null) { return(DeserializeValue <T>(CreateReader(stream, context, format), referencedUnityObjects)); } else { using (var con = Cache <DeserializationContext> .Claim()) { return(DeserializeValue <T>(CreateReader(stream, con, format), referencedUnityObjects)); } } }