Beispiel #1
0
        public void ReadValue(ref ShockwaveReader input, int dataOffset)
        {
            if (Kind != LiteralKind.Integer)
            {
                input.Position = dataOffset + Offset;

                int length = input.ReadInt32();
                Value = Kind switch
                {
                    LiteralKind.String => input.ReadString(length),
                    LiteralKind.FloatingPoint => input.ReadDouble(),
                    LiteralKind.CompiledJavascript => input.ReadBytes(length).ToArray()
                };
            }
            else
            {
                Value = Offset;
            }
        }
Beispiel #2
0
        public static LingoLiteral Read(ref ShockwaveReader input, LiteralKind entryKind, int entryOffset)
        {
            if (entryKind != LiteralKind.Integer)
            {
                input.Position = entryOffset;

                int    length = input.ReadInt32();
                object value  = entryKind switch
                {
                    LiteralKind.String => input.ReadString(length),
                    LiteralKind.FloatingPoint => input.ReadDouble(),
                    LiteralKind.CompiledJavascript => input.ReadBytes(length).ToArray(),

                    _ => throw new ArgumentException(nameof(Kind))
                };

                return(new LingoLiteral(entryKind, value));
            }
            else
            {
                return(new LingoLiteral(LiteralKind.Integer, entryOffset));
            }
        }