Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
 internal static PropertyDatabaseRecordValue BooleanSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Bool, (bool)args.value));
 }
Beispiel #5
0
 internal static PropertyDatabaseRecordValue UnsignedLongSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.UnsignedLong, (ulong)args.value));
 }
Beispiel #6
0
 internal static PropertyDatabaseRecordValue ShortSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Short, (short)args.value));
 }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
 internal static PropertyDatabaseRecordValue FloatSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Float, (float)args.value));
 }
Beispiel #10
0
 internal static PropertyDatabaseRecordValue DoubleSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Double, (double)args.value));
 }
Beispiel #11
0
 internal static PropertyDatabaseRecordValue IntegerSerializer(PropertyDatabaseSerializationArgs args)
 {
     return(new PropertyDatabaseRecordValue((byte)PropertyDatabaseType.Integer, (int)args.value));
 }