public static void FromUnityJsonDataOverwrite(UnityJsonData p_data, object p_target, Serializer p_serializer = null, UnityObjectConverter p_customConverter = null) { if (p_data != null) { p_serializer = LockSerializer(p_serializer); try { var v_oldConverter = p_serializer.GetConverter(typeof(Object)); if (v_oldConverter == null || !v_oldConverter.GetType().IsSubclassOf(typeof(UnityObjectConverter))) { var v_converter = p_customConverter == null ? new UnityObjectConverter() : p_customConverter; p_serializer.AddConverter(v_converter); } else if (v_oldConverter != null && p_customConverter != null && p_customConverter.GetType() != v_oldConverter.GetType()) { p_serializer.AddConverter(p_customConverter); } p_serializer.Context.Set(p_data.Context); FromJson_UnsafeInternal(ref p_target, p_data.Json, p_target.GetType(), p_serializer); } finally { UnlockSerializer(p_serializer); } } }
public static object FromUnityJsonData(UnityJsonData p_data, System.Type p_type, Serializer p_serializer = null, UnityObjectConverter p_customConverter = null) { object v_target = null; if (p_data != null) { p_serializer = LockSerializer(p_serializer); try { var v_oldConverter = p_serializer.GetConverter(typeof(Object)); if (v_oldConverter == null || !v_oldConverter.GetType().IsSubclassOf(typeof(UnityObjectConverter))) { var v_converter = p_customConverter == null ? new UnityObjectConverter() : p_customConverter; p_serializer.AddConverter(v_converter); } else if (v_oldConverter != null && p_customConverter != null && p_customConverter.GetType() != v_oldConverter.GetType()) { p_serializer.AddConverter(p_customConverter); } p_serializer.Context.Set(p_data.Context); FromJson_UnsafeInternal(ref v_target, p_data.Json, p_type, p_serializer); } finally { UnlockSerializer(p_serializer); } } return(v_target); }
public static T FromUnityJsonData <T>(UnityJsonData p_data, Serializer p_serializer = null, UnityObjectConverter p_customConverter = null) { if (p_data != null) { return((T)FromUnityJsonData(p_data, typeof(T), p_serializer, p_customConverter)); } return(default(T)); }
public static UnityJsonData ToUnityJsonData(object p_obj, System.Type p_type, Serializer p_serializer = null, UnityObjectConverter p_customConverter = null) { if (p_obj != null) { p_serializer = LockSerializer(p_serializer); try { List <Object> v_context = new List <Object>(); var v_oldConverter = p_serializer.GetConverter(typeof(Object)); if (v_oldConverter == null || !v_oldConverter.GetType().IsSubclassOf(typeof(UnityObjectConverter))) { var v_converter = p_customConverter == null ? new UnityObjectConverter() : p_customConverter; p_serializer.AddConverter(v_converter); } else if (v_oldConverter != null && p_customConverter != null && p_customConverter.GetType() != v_oldConverter.GetType()) { p_serializer.AddConverter(p_customConverter); } p_serializer.Context.Set(v_context); var v_data = new UnityJsonData(); v_data.Json = ToJson_UnsafeInternal(p_obj, p_type, false, p_serializer); v_data.Context = v_context; return(v_data); } finally { UnlockSerializer(p_serializer); } } return(null); }