Ejemplo n.º 1
0
        /// <summary>
        /// Make new flag parameters.
        /// </summary>
        /// <param name="br">The reader.</param>
        public FlagParameters(ref BinaryDataReader br)
        {
            //Read the UInt32 that has flags enabled, and convert to an array of booleans.
            UInt32 flagsEnabled = br.ReadUInt32();

            isFlagEnabled = new bool[32];
            for (int i = 0; i < 32; i++)
            {
                //See if bit at i is set.
                if (BitHelperUInt.IsBitSet(flagsEnabled, i))
                {
                    isFlagEnabled[i] = true;
                }
            }

            //Read enabled values.
            flagValues = new UInt32[32];
            for (int i = 0; i < isFlagEnabled.Length; i++)
            {
                if (isFlagEnabled[i])
                {
                    flagValues[i] = br.ReadUInt32();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Write flag parameters.
        /// </summary>
        /// <param name="bw">The writer.</param>
        public void Write(ref BinaryDataWriter bw)
        {
            //Write which flags are enabled.
            UInt32 flagsEnabled = 0;

            for (int i = 0; i < 32; i++)
            {
                if (isFlagEnabled[i])
                {
                    BitHelperUInt.SetBit(ref flagsEnabled, i, true);
                }
            }
            bw.Write(flagsEnabled);

            //Write the enabled values.
            for (int i = 0; i < 32; i++)
            {
                if (isFlagEnabled[i])
                {
                    bw.Write(flagValues[i]);
                }
            }
        }