private Token DecodeToken()
        {
            var tokenBuilder = new Token.Builder();
            var encBuilder = new Encoding.Builder();

            _tokenCodec.WrapForDecode(_directBuffer, _offset, TokenCodec.BlockLength, 0);

            tokenBuilder
                .Offset(_tokenCodec.TokenOffset)
                .Size(_tokenCodec.TokenSize)
                .SchemaId(_tokenCodec.SchemaId)
                .Version(_tokenCodec.TokenVersion)
                .Signal(IrUtil.MapSignal(_tokenCodec.Signal));

            PrimitiveType type = IrUtil.MapPrimitiveType(_tokenCodec.PrimitiveType);

            encBuilder
                .PrimitiveType(IrUtil.MapPrimitiveType(_tokenCodec.PrimitiveType))
                .ByteOrder(IrUtil.MapByteOrder(_tokenCodec.ByteOrder))
                .Presence(IrUtil.MapPresence(_tokenCodec.Presence));

            int stringLength = _tokenCodec.GetName(_buffer, 0, _buffer.Length);
            System.Text.Encoding encoding = System.Text.Encoding.GetEncoding(TokenCodec.NameCharacterEncoding);
            string value = encoding.GetString(_buffer, 0, stringLength);
            tokenBuilder.Name(value);

            encBuilder.ConstValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetConstValue(_valArray, 0, _valArray.Length)));
            encBuilder.MinValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetMinValue(_valArray, 0, _valArray.Length)));
            encBuilder.MaxValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetMaxValue(_valArray, 0, _valArray.Length)));
            encBuilder.NullValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetNullValue(_valArray, 0, _valArray.Length)));

            // character encoding
            stringLength = _tokenCodec.GetCharacterEncoding(_buffer, 0, _buffer.Length);
            encoding = System.Text.Encoding.GetEncoding(TokenCodec.CharacterEncodingCharacterEncoding);
            value = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.CharacterEncoding(value.Length == 0 ? null : value);

            // epoch
            stringLength = _tokenCodec.GetEpoch(_buffer, 0, _buffer.Length);
            encoding = System.Text.Encoding.GetEncoding(TokenCodec.EpochCharacterEncoding);
            value = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.Epoch(value.Length == 0 ? null : value);

            // time unit
            stringLength = _tokenCodec.GetTimeUnit(_buffer, 0, _buffer.Length);
            encoding = System.Text.Encoding.GetEncoding(TokenCodec.TimeUnitCharacterEncoding);
            value = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.TimeUnit(value.Length == 0 ? null : value);

            // semantic type
            stringLength = _tokenCodec.GetSemanticType(_buffer, 0, _buffer.Length);
            encoding = System.Text.Encoding.GetEncoding(TokenCodec.SemanticTypeCharacterEncoding);
            value = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.SemanticType(value.Length == 0 ? null : value);

            _offset += _tokenCodec.Size;

            return tokenBuilder.Encoding(encBuilder.Build()).Build();
        }
        private Token DecodeToken()
        {
            var tokenBuilder = new Token.Builder();
            var encBuilder   = new Encoding.Builder();

            _tokenCodec.WrapForDecode(_directBuffer, _offset, TokenCodec.BlockLength, 0);

            tokenBuilder
            .Offset(_tokenCodec.TokenOffset)
            .Size(_tokenCodec.TokenSize)
            .SchemaId(_tokenCodec.SchemaId)
            .Version(_tokenCodec.TokenVersion)
            .Signal(IrUtil.MapSignal(_tokenCodec.Signal));

            PrimitiveType type = IrUtil.MapPrimitiveType(_tokenCodec.PrimitiveType);

            encBuilder
            .PrimitiveType(IrUtil.MapPrimitiveType(_tokenCodec.PrimitiveType))
            .ByteOrder(IrUtil.MapByteOrder(_tokenCodec.ByteOrder))
            .Presence(IrUtil.MapPresence(_tokenCodec.Presence));

            int stringLength = _tokenCodec.GetName(_buffer, 0, _buffer.Length);

            System.Text.Encoding encoding = System.Text.Encoding.GetEncoding(TokenCodec.NameCharacterEncoding);
            string value = encoding.GetString(_buffer, 0, stringLength);

            tokenBuilder.Name(value);

            encBuilder.ConstValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetConstValue(_valArray, 0, _valArray.Length)));
            encBuilder.MinValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetMinValue(_valArray, 0, _valArray.Length)));
            encBuilder.MaxValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetMaxValue(_valArray, 0, _valArray.Length)));
            encBuilder.NullValue(IrUtil.Get(_valBuffer, type, _tokenCodec.GetNullValue(_valArray, 0, _valArray.Length)));

            // character encoding
            stringLength = _tokenCodec.GetCharacterEncoding(_buffer, 0, _buffer.Length);
            encoding     = System.Text.Encoding.GetEncoding(TokenCodec.CharacterEncodingCharacterEncoding);
            value        = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.CharacterEncoding(value.Length == 0 ? null : value);

            // epoch
            stringLength = _tokenCodec.GetEpoch(_buffer, 0, _buffer.Length);
            encoding     = System.Text.Encoding.GetEncoding(TokenCodec.EpochCharacterEncoding);
            value        = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.Epoch(value.Length == 0 ? null : value);

            // time unit
            stringLength = _tokenCodec.GetTimeUnit(_buffer, 0, _buffer.Length);
            encoding     = System.Text.Encoding.GetEncoding(TokenCodec.TimeUnitCharacterEncoding);
            value        = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.TimeUnit(value.Length == 0 ? null : value);

            // semantic type
            stringLength = _tokenCodec.GetSemanticType(_buffer, 0, _buffer.Length);
            encoding     = System.Text.Encoding.GetEncoding(TokenCodec.SemanticTypeCharacterEncoding);
            value        = encoding.GetString(_buffer, 0, stringLength);
            encBuilder.SemanticType(value.Length == 0 ? null : value);

            _offset += _tokenCodec.Size;

            return(tokenBuilder.Encoding(encBuilder.Build()).Build());
        }