Esempio n. 1
0
            /// <summary>
            /// Masks bits from the source based on the given count and <see cref="CurrentByteOffset"/> and adds them to the container.
            /// </summary>
            /// <param name="container">The container to move bits into.</param>
            /// <param name="source">The source byte containing the bits to copy.</param>
            /// <param name="bitCount">The number of bits to copy.</param>
            protected virtual void MaskAndCopyBits(ref TBitContainer container, byte source, int bitCount)
            {
                var mask = BitHelpers.GetLeftMaskByte(bitCount) >> CurrentByteOffset;

                var bits = (byte)((source & mask) >> (BitsInByte - bitCount - CurrentByteOffset));

                Enumerable.AddToContainer(ref container, bits, bitCount);
            }