Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.Config.getTokenDis C# (CSharp) Méthode

getTokenDis() public static méthode

Get a match token according to the match distance.
public static getTokenDis ( int distance ) : Token
distance int The distance here means the needed bytes backward.
Résultat Token
        public static Token getTokenDis(int distance)
        {
            if (distance < 32)
                return tokenTableDis[1];
            else if (distance < 160)
                return tokenTableDis[2];
            else if (distance < 672)
                return tokenTableDis[3];
            else if (distance < 1696)
                return tokenTableDis[4];
            else if (distance < 5792)
                return tokenTableDis[5];
            else if (distance < 22176)
                return tokenTableDis[8];
            else if (distance < 54944)
                return tokenTableDis[9];
            else
                return tokenTableDis[13];
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Add the a match to the result bit buffer.
        /// </summary>
        /// <param name="distance">The number of bytes backward to copy from.</param>
        /// <param name="length">The total number of bytes to be copied.</param>
        private void addCompressBytes(int distance, int length)
        {
            Token token = Config.getTokenDis(distance);

            bitBuffer.AddRange(convertStringToBits(token.BitPrefix));
            bitBuffer.AddRange(convertIntToBits(distance - token.Vbase, token.ValueBits));
            int exp = 1;

            while (length >= Math.Pow(2, exp))
            {
                ++exp;
            }
            token = Config.getTokenLen(length);
            bitBuffer.AddRange(convertStringToBits(token.BitPrefix));
            bitBuffer.AddRange(convertIntToBits(length - (int)Math.Pow(2, exp - 1), token.ValueBits));
        }