Example #1
0
        private void SetValue(ElementInfoIndex index, int value)
        {
            ElementInfo info = ElementInfos[(int)index];

            int newValue = Storage[info.ByteOffset] & ~(~(-1 << info.BitWidth) << info.BitOffset) | (((value - info.MinValue) & ~(-1 << info.BitWidth)) << info.BitOffset);

            Storage[info.ByteOffset] = (byte)newValue;
        }
Example #2
0
        private bool IsElementValid(ElementInfoIndex index)
        {
            ElementInfo info = ElementInfos[(int)index];

            int value = GetValue(index);

            return(value >= info.MinValue && value <= info.MaxValue);
        }
Example #3
0
        private int GetValue(ElementInfoIndex index)
        {
            ElementInfo info = ElementInfos[(int)index];

            return(((Storage[info.ByteOffset] >> info.BitOffset) & ~(-1 << info.BitWidth)) + info.MinValue);
        }