Exemple #1
0
        public static object Deserialize(Stream input, FieldType type, bool littleEndian)
        {
            switch (type)
            {
                case FieldType.UInt8: return input.ReadValueU8();
                case FieldType.Int8: return input.ReadValueS8();
                case FieldType.UInt16: return input.ReadValueU16(littleEndian);
                case FieldType.Int16: return input.ReadValueS16(littleEndian);
                case FieldType.UInt32: return input.ReadValueU32(littleEndian);
                case FieldType.Int32: return input.ReadValueS32(littleEndian);
                case FieldType.UInt64: return input.ReadValueU64(littleEndian);
                case FieldType.Int64: return input.ReadValueS64(littleEndian);
                case FieldType.Single: return input.ReadValueF32(littleEndian);
                case FieldType.Double: return input.ReadValueF64(littleEndian);
                case FieldType.Vector3:
                {
                    var value = new Builtins.Vector3();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Vector4:
                {
                    var value = new Builtins.Vector4();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Quaternion:
                {
                    var value = new Builtins.Quaternion();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.String:
                {
                    throw new NotSupportedException("cannot deserialize strings via Builtin");
                }
                case FieldType.Color:
                {
                    var value = new Builtins.Color();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
                case FieldType.Matrix4x4:
                {
                    var value = new Builtins.Matrix4x4();
                    value.Deserialize(input, littleEndian);
                    return value;
                }
            }

            throw new NotSupportedException("unsupported builtin type");
        }
Exemple #2
0
        public static object Deserialize(Stream input, FieldType type, Endian endian)
        {
            switch (type)
            {
            case FieldType.UInt8: return(input.ReadValueU8());

            case FieldType.Int8: return(input.ReadValueS8());

            case FieldType.UInt16: return(input.ReadValueU16(endian));

            case FieldType.Int16: return(input.ReadValueS16(endian));

            case FieldType.UInt32: return(input.ReadValueU32(endian));

            case FieldType.Int32: return(input.ReadValueS32(endian));

            case FieldType.UInt64: return(input.ReadValueU64(endian));

            case FieldType.Int64: return(input.ReadValueS64(endian));

            case FieldType.Single: return(input.ReadValueF32(endian));

            case FieldType.Double: return(input.ReadValueF64(endian));

            case FieldType.Vector3:
            {
                var value = new Builtins.Vector3();
                value.Deserialize(input, endian);
                return(value);
            }

            case FieldType.Vector4:
            {
                var value = new Builtins.Vector4();
                value.Deserialize(input, endian);
                return(value);
            }

            case FieldType.Quaternion:
            {
                var value = new Builtins.Quaternion();
                value.Deserialize(input, endian);
                return(value);
            }

            case FieldType.String:
            {
                throw new NotSupportedException("cannot deserialize strings via Builtin");
            }

            case FieldType.Color:
            {
                var value = new Builtins.Color();
                value.Deserialize(input, endian);
                return(value);
            }

            case FieldType.Matrix4x4:
            {
                var value = new Builtins.Matrix4x4();
                value.Deserialize(input, endian);
                return(value);
            }
            }

            throw new NotSupportedException("unsupported builtin type");
        }