internal static PropertyDatabaseRecordValue GlobalObjectIdSerializer(PropertyDatabaseSerializationArgs args) { var goid = (GlobalObjectId)args.value; var str = goid.ToString(); var symbol = args.stringTableView.ToSymbol(str); return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.GlobalObjectId, symbol)); }
public static PropertyDatabaseRecordValue Serialize(object value, PropertyStringTableView stringTableView) { var type = value.GetType(); if (!s_Serializers.ContainsKey(type)) { return(PropertyDatabaseRecordValue.invalid); } var args = new PropertyDatabaseSerializationArgs(value, stringTableView); return(s_Serializers[type].handler(args)); }
internal static PropertyDatabaseRecordValue StringSerializer(PropertyDatabaseSerializationArgs args) { var stringValue = (string)args.value; var byteSize = PropertyStringTable.encoding.GetByteCount(stringValue); if (byteSize + fixedStringLengthByteSize <= PropertyDatabaseRecordValue.maxSize) { var bytes = new byte[byteSize + fixedStringLengthByteSize]; SetFixedStringLength(bytes, byteSize); PropertyStringTable.encoding.GetBytes(stringValue, 0, stringValue.Length, bytes, fixedStringLengthByteSize); return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.FixedString, bytes)); } var symbol = args.stringTableView.ToSymbol(stringValue); return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.String, symbol)); }
internal static PropertyDatabaseRecordValue BooleanSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Bool, (bool)args.value)); }
internal static PropertyDatabaseRecordValue UnsignedLongSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.UnsignedLong, (ulong)args.value)); }
internal static PropertyDatabaseRecordValue ShortSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Short, (short)args.value)); }
internal static PropertyDatabaseRecordValue Color32Serializer(PropertyDatabaseSerializationArgs args) { var color = (Color32)args.value; return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Color32, color.r, color.g, color.b, color.a)); }
internal static PropertyDatabaseRecordValue Vector4Serializer(PropertyDatabaseSerializationArgs args) { var v = (Vector4)args.value; return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Vector4, v.x, v.y, v.z, v.w)); }
internal static PropertyDatabaseRecordValue FloatSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Float, (float)args.value)); }
internal static PropertyDatabaseRecordValue DoubleSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Double, (double)args.value)); }
internal static PropertyDatabaseRecordValue IntegerSerializer(PropertyDatabaseSerializationArgs args) { return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Integer, (int)args.value)); }