Ejemplo n.º 1
0
        /// <inheritdoc cref="AbstractClientSocket.ExecuteRequest" />
        public override byte[] ExecuteRequest
        (
            byte[] request
        )
        {
            Sure.NotNull(request, nameof(request));

            ActualRequest = request;

            if (!ReferenceEquals(ExpectedRequest, null))
            {
                if (!ArrayUtility.Coincide(ExpectedRequest, 0, request, 0, request.Length))
                {
                    throw new Exception();
                }
            }

            byte[] answer = Response;
            if (ReferenceEquals(answer, null))
            {
                throw new Exception();
            }

            return(answer);
        }
Ejemplo n.º 2
0
        public TextBuffer RemoveEmptyLines()
        {
            char[] newLine = Environment.NewLine.ToCharArray();
            int    len     = newLine.Length;

            while (_length > len)
            {
                if (!ArrayUtility.Coincide
                    (
                        _array,
                        _length - len,
                        newLine,
                        0,
                        len
                    ))
                {
                    break;
                }

                _length -= len;
                _line--;
                _column = 1;
                _CalculateColumn();
            }

            return(this);
        }
Ejemplo n.º 3
0
 public void ArrayUtility_Coincide_1()
 {
     int[] first  = { 1, 2, 3, 4, 5, 6, 7 };
     int[] second = { 3, 4, 5, 6, 7, 8, 9 };
     Assert.IsTrue(ArrayUtility.Coincide(first, 3, second, 1, 2));
     Assert.IsFalse(ArrayUtility.Coincide(first, 3, second, 2, 2));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Предваряется явным переводом строки?
        /// </summary>
        public bool PrecededByNewLine()
        {
            char[] newLine = Environment.NewLine.ToCharArray();
            int    len     = newLine.Length;

            if (_length < len)
            {
                return(false);
            }

            bool result = ArrayUtility.Coincide
                          (
                _array,
                _length - len,
                newLine,
                0,
                len
                          );

            return(result);
        }