HttpMultipartParser.SubsequenceFinder.Search C# (CSharp) Method

Search() public static method

public static Search ( byte haystack, byte needle ) : int
haystack byte
needle byte
return int
        public static int Search(byte[] haystack, byte[] needle)
        {
            return Search(haystack, needle, haystack.Length);
        }

Same methods

SubsequenceFinder::Search ( byte haystack, byte needle, int haystackLength ) : int

Usage Example

Beispiel #1
0
        /// <summary>
        /// Finds the next sequence of newlines in the input stream.
        /// </summary>
        /// <param name="data">The data to search</param>
        /// <param name="offset">The offset to start searching at</param>
        /// <param name="maxBytes">The maximum number of bytes (starting from offset) to search.</param>
        /// <returns>The offset of the next newline</returns>
        private int FindNextNewline(ref byte[] data, int offset, int maxBytes)
        {
            byte[][] newlinePatterns = { this.Encoding.GetBytes("\r\n"), this.Encoding.GetBytes("\n") };
            Array.Sort(newlinePatterns, (first, second) => second.Length.CompareTo(first.Length));

            byte[] dataRef = data;
            if (offset != 0)
            {
                dataRef = data.Skip(offset).ToArray();
            }

            foreach (var pattern in newlinePatterns)
            {
                int position = SubsequenceFinder.Search(dataRef, pattern);
                if (position != -1)
                {
                    return(position + offset);
                }
            }

            return(-1);
        }
All Usage Examples Of HttpMultipartParser.SubsequenceFinder::Search
SubsequenceFinder