ArtemisComm.VariablePackage.ProcessBitFlags C# (CSharp) Méthode

ProcessBitFlags() public static méthode

public static ProcessBitFlags ( int propertyCount, MemoryStream stream, int index ) : bool[]
propertyCount int
stream System.IO.MemoryStream
index int
Résultat bool[]
        public static bool[] ProcessBitFlags(int propertyCount, MemoryStream stream, int index)
        {
            if (stream != null)
            {
                stream.Position = index;

                List<bool> IncludedList = new List<bool>();


                int k = 1;
              
                int FlagSize = 1;

                byte wrkByte = Convert.ToByte(stream.ReadByte());

                for (int i = 0; i < propertyCount; i++)
                {
                    //1, 2, 4, 8, 16, 32, 64, 128
                    bool test = ((wrkByte & k) == k);
                    IncludedList.Add(test);
                    k *= 2;
                    if (k > 128)
                    {
                        k = 1;
                        wrkByte = Convert.ToByte(stream.ReadByte());
                        FlagSize++;
                    }

                }

                return IncludedList.ToArray();
            }
            else
            {
                return null;
            }
        }