public StringBuildingState ProcessByte(byte inputByte, ref string destinationString)
        {
            if (inputByte == 0)
            {
                return(StringBuildingState.StringComplete);
            }

            destinationString += ByteToStringConverter.ConvertToEscapedString(inputByte);

            return(StringBuildingState.MoreBytesRequired);
        }
示例#2
0
        public StringBuildingState ProcessByte(byte inputByte, ref string destinationString)
        {
            if (bytesProcessedSoFar >= desiredNumberOfBytes)
            {
                throw new InvalidOperationException("The desired number of bytes have already been processed.");
            }

            destinationString += ByteToStringConverter.ConvertToEscapedString(inputByte);

            bytesProcessedSoFar++;

            if (bytesProcessedSoFar == desiredNumberOfBytes)
            {
                return(StringBuildingState.StringComplete);
            }
            else
            {
                return(StringBuildingState.MoreBytesRequired);
            }
        }