Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BeginEndMarkReceiveFilter{TPackageInfo}"/> class.
 /// </summary>
 /// <param name="beginMark">The begin mark.</param>
 /// <param name="endMark">The end mark.</param>
 /// <param name="fixedlen">The fixed length.</param>
 public BeginEndMarkFixedBodyReceiveFilter(byte[] beginMark, byte[] endMark, int fixedlen)
 {
     m_BeginSearchState = new SearchMarkState <byte>(beginMark);
     m_EndSearchState   = new SearchMarkState <byte>(endMark);
     m_FixedLen         = fixedlen;
     m_packagelenbuffer = new byte[m_FixedLen];
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CountSpliterReceiveFilter{TPackageInfo}"/> class.
 /// </summary>
 /// <param name="spliter">The spliter.</param>
 /// <param name="spliterCount">The spliter count.</param>
 protected CountSpliterReceiveFilter(byte[] spliter, int spliterCount)
 {
     m_SpliterSearchState = new SearchMarkState <byte>(spliter);
     m_SpliterCount       = spliterCount;
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BeginEndMarkReceiveFilter{TPackageInfo}"/> class.
 /// </summary>
 /// <param name="beginMark">The begin mark.</param>
 /// <param name="endMark">The end mark.</param>
 public BeginEndMarkReceiveFilter(byte[] beginMark, byte[] endMark)
 {
     m_BeginSearchState = new SearchMarkState <byte>(beginMark);
     m_EndSearchState   = new SearchMarkState <byte>(endMark);
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TerminatorReceiveFilter{TPackageInfo}"/> class.
 /// </summary>
 /// <param name="terminator">The terminator.</param>
 protected TerminatorReceiveFilter(byte[] terminator)
 {
     m_SearchState = new SearchMarkState <byte>(terminator);
 }
Beispiel #5
0
        /// <summary>
        /// Searches the mark from source.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">The source.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="length">The length.</param>
        /// <param name="searchState">State of the search.</param>
        /// <param name="parsedLength">Length of the parsed.</param>
        /// <returns></returns>
        public static int SearchMark <T>(this IList <T> source, int offset, int length, SearchMarkState <T> searchState, out int parsedLength)
            where T : IEquatable <T>
        {
            int?result = source.SearchMark(offset, length, searchState.Mark, searchState.Matched, out parsedLength);

            if (!result.HasValue)
            {
                searchState.Matched = 0;
                return(-1);
            }

            if (result.Value < 0)
            {
                searchState.Matched = 0 - result.Value;
                return(-1);
            }

            searchState.Matched = 0;
            return(result.Value);
        }