예제 #1
0
파일: Construct.cs 프로젝트: fossabot/Melt
        public Construct Attach(Type type, object value)
        {
            var c     = _pool.Get(type);
            var bytes = c.ToBytes(value, _pool);

            if (bytes != null)
            {
                _bytes.AddRange(bytes);
            }
            return(this);
        }
예제 #2
0
        public object Detach(Type type, out int length)
        {
            var span = _bytes.AsSpan(_index);

            var marshaller = _pool.Get(type);

            var result = marshaller.FromBytes(span.ToArray(), out var spanLength, _pool);

            _index += spanLength;
            length  = _index;
            return(result);
        }