Пример #1
0
        public bool TryParseScript(ref ByteSequenceReader reader, IBlockParser bp, bool withoutLength = false)
        {
            var length = reader.Data.Remaining;

            if (!withoutLength && !reader.TryReadVariant(out length))
            {
                goto fail;
            }

            bp.ScriptStart(this, reader.Data.Consumed);

            if (reader.Data.Remaining < length)
            {
                goto fail;
            }

            _script = (VarType)(ReadOnlyByteSequence)reader.Data.Sequence.Slice(reader.Data.Position, length);
            reader.Data.Advance(length);

            bp.ScriptParsed(this, reader.Data.Consumed);

            return(true);

fail:
            return(false);
        }
Пример #2
0
        public bool TryReadScript(ref ByteSequenceReader r, bool withoutLength = false)
        {
            var length = r.Data.Remaining;

            if (!withoutLength && !r.TryReadVariant(out length))
            {
                goto fail;
            }

            if (r.Data.Remaining < length)
            {
                goto fail;
            }

            _script = (VarType)(ReadOnlyByteSequence)r.Data.Sequence.Slice(r.Data.Position, length);
            r.Data.Advance(length);

            return(true);

fail:
            return(false);
        }