<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase.Command;
using SuperSocket.Common;
using SuperSocket.SocketBase.Config;

namespace SuperSocket.SocketBase.Protocol
{
    public abstract class CommandReaderBase<TCommandInfo> : ICommandReader<TCommandInfo>
        where TCommandInfo : ICommandInfo
    {
        private readonly ArraySegmentList<byte> m_BufferSegments;

        protected ArraySegmentList<byte> BufferSegments
        {
            get { return m_BufferSegments; }
        }

        private CommandReaderBase()
        {

        }

        public CommandReaderBase(IAppServer appServer)
        {
            AppServer = appServer;
            m_BufferSegments = new ArraySegmentList<byte>();
        }

        public CommandReaderBase(ICommandReader<TCommandInfo> previousCommandReader)
        {
            AppServer = previousCommandReader.AppServer;
            m_BufferSegments = previousCommandReader.GetLeftBuffer();
        }

        #region ICommandReader<TCommandInfo> Members

        public IAppServer AppServer { get; private set; }

        public abstract TCommandInfo FindCommand(SocketContext context, byte[] readBuffer, int offset, int length, bool isReusableBuffer);

        public ArraySegmentList<byte> GetLeftBuffer()
        {
            return m_BufferSegments;
        }

        public ICommandReader<TCommandInfo> NextCommandReader { get; protected set; }

        #endregion
    }
}<commit_msg>mainline: added a method in CommandReaderBase class<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase.Command;
using SuperSocket.Common;
using SuperSocket.SocketBase.Config;

namespace SuperSocket.SocketBase.Protocol
{
    public abstract class CommandReaderBase<TCommandInfo> : ICommandReader<TCommandInfo>
        where TCommandInfo : ICommandInfo
    {
        private readonly ArraySegmentList<byte> m_BufferSegments;

        protected ArraySegmentList<byte> BufferSegments
        {
            get { return m_BufferSegments; }
        }

        private CommandReaderBase()
        {

        }

        public CommandReaderBase(IAppServer appServer)
        {
            AppServer = appServer;
            m_BufferSegments = new ArraySegmentList<byte>();
        }

        public CommandReaderBase(ICommandReader<TCommandInfo> previousCommandReader)
        {
            AppServer = previousCommandReader.AppServer;
            m_BufferSegments = previousCommandReader.GetLeftBuffer();
        }

        #region ICommandReader<TCommandInfo> Members

        public IAppServer AppServer { get; private set; }

        public abstract TCommandInfo FindCommand(SocketContext context, byte[] readBuffer, int offset, int length, bool isReusableBuffer);

        public ArraySegmentList<byte> GetLeftBuffer()
        {
            return m_BufferSegments;
        }

        public ICommandReader<TCommandInfo> NextCommandReader { get; protected set; }

        #endregion

        protected void AddArraySegment(byte[] buffer, int offset, int length, bool isReusableBuffer)
        {
            if (isReusableBuffer)
                BufferSegments.AddSegment(new ArraySegment<byte>(buffer.CloneRange(offset, length)));
            else
                BufferSegments.AddSegment(new ArraySegment<byte>(buffer, offset, length));
        }
    }
}
{'fraction_non_alphanumeric': 0.06882591093117409, 'fraction_numerical': 0.0, 'mean_word_length': 2.830564784053156, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6713413', 'n_tokens_mistral': 881, 'n_tokens_neox': 857, 'n_words': 196}