// 把值写入到ab当中 void ITypeSerialize.WriteTo(object value, Nested.AnyBase ab) { if (value == null) { ab.typeName = string.Empty; return; } var type = IL.Help.GetInstanceType(value); var serial = type == baseType ? baseTypeSerialize : BinarySerializable.GetByType(type); ab.typeName = type.FullName; serial.WriteTo(value, ab); }
// 把值写入到ab当中 void ITypeSerialize.WriteTo(object value, Nested.AnyBase ab) { if (value == null) { ab.valueType = 0; return; } ab.valueType = 1; var type = IL.Help.GetInstanceType(value); var serial = BinarySerializable.GetByType(type); TypeDesc typeDesc = TypeDesc.Get(type); ab.typeName = typeDesc.ToBase64(); serial.WriteTo(value, ab); }
// 通过ab来设置值 void ITypeSerialize.MergeFrom(ref object value, Nested.AnyBase ab) { if (ab.valueType == 0) { value = null; return; } var typeDesc = TypeDesc.CreateByBase64(ab.typeName); System.Type type = typeDesc.GetCurrentType(); if (value == null || (IL.Help.GetInstanceType(value) != type)) { value = IL.Help.Create(type); } var serial = BinarySerializable.GetByType(type); serial.MergeFrom(ref value, ab); }
// 通过ab来设置值 void ITypeSerialize.MergeFrom(ref object value, Nested.AnyBase ab) { string fullName = ab.typeName; if (string.IsNullOrEmpty(fullName)) { return; } System.Type type; if (value == null || ((type = IL.Help.GetInstanceType(value)).FullName != fullName)) { if (IL.Help.TryGetTypeByFullName(fullName, out type)) { value = IL.Help.Create(type); } } var serial = type == baseType ? baseTypeSerialize : BinarySerializable.GetByType(type); serial.MergeFrom(ref value, ab); }
// 通过ab来设置值 void ITypeSerialize.MergeFrom(ref object value, Nested.AnyBase ab) { value = ab.unityObj; }
// 把值写入到ab当中 void ITypeSerialize.WriteTo(object value, Nested.AnyBase ab) { ab.unityObj = value as UnityEngine.Object; }