Beispiel #1
0
        /// <nodoc />
        public static MachineIdSet Deserialize(BuildXLReader reader)
        {
            var format = (SetFormat)reader.ReadByte();

            if (format == SetFormat.Bits)
            {
                return(BitMachineIdSet.DeserializeCore(reader));
            }
            else
            {
                return(ArrayMachineIdSet.DeserializeCore(reader));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns true if deserialized instance would have a machine id with a given index.
        /// </summary>
        public static bool HasMachineId(BuildXLReader reader, int index)
        {
            var format = (SetFormat)reader.ReadByte();

            if (format == SetFormat.Bits)
            {
                return(BitMachineIdSet.HasMachineIdCore(reader, index));
            }
            else
            {
                return(ArrayMachineIdSet.HasMachineIdCore(reader, index));
            }
        }
Beispiel #3
0
        /// <nodoc />
        public void Serialize(BuildXLWriter writer)
        {
            MachineIdSet serializableInstance = this;

            if (Format == SetFormat.Bits)
            {
                if (Count <= BitMachineIdSetThreshold)
                {
                    serializableInstance = new ArrayMachineIdSet(EnumerateMachineIds().Select(id => (ushort)id.Index).ToArray());
                }
            }
            else
            {
                if (Count > BitMachineIdSetThreshold)
                {
                    serializableInstance = BitMachineIdSet.EmptyInstance.SetExistence(this, exists: true);
                }
            }

            writer.Write((byte)serializableInstance.Format);
            serializableInstance.SerializeCore(writer);
        }