Esempio n. 1
0
 /// <summary>
 /// Writes an enumeration of <see cref="Boolean"/> values in the given format to the current stream, with 0
 /// representing <c>false</c> and 1 representing <c>true</c>.
 /// </summary>
 /// <param name="values">The <see cref="Boolean"/> values to write.</param>
 /// <param name="format">The binary format in which the <see cref="Boolean"/> values will be written.</param>
 public void Write(IEnumerable <Boolean> values, BinaryBooleanFormat format)
 {
     foreach (bool value in values)
     {
         Write(value, format);
     }
 }
 /// <summary>
 /// Writes a <see cref="Vector3Bool"/> instance into the current stream.
 /// </summary>
 /// <param name="self">The extended <see cref="BinaryDataWriter"/>.</param>
 /// <param name="value">The <see cref="Vector3Bool"/> instance.</param>
 /// <param name="format">The <see cref="BinaryBooleanFormat"/> in which values are stored.</param>
 public static void Write(this BinaryDataWriter self, Vector3Bool value,
                          BinaryBooleanFormat format = BinaryBooleanFormat.NonZeroByte)
 {
     self.Write(value.X, format);
     self.Write(value.Y, format);
     self.Write(value.Z, format);
 }
 /// <summary>
 /// Writes <see cref="Vector4Bool"/> instances into the current stream.
 /// </summary>
 /// <param name="self">The extended <see cref="BinaryDataWriter"/>.</param>
 /// <param name="values">The <see cref="Vector4Bool"/> instances.</param>
 /// <param name="format">The <see cref="BinaryBooleanFormat"/> in which values are stored.</param>
 public static void Write(this BinaryDataWriter self, IEnumerable <Vector4Bool> values,
                          BinaryBooleanFormat format = BinaryBooleanFormat.NonZeroByte)
 {
     foreach (Vector4Bool value in values)
     {
         self.Write(value, format);
     }
 }
 /// <summary>
 /// Reads the specified number of <see cref="Boolean"/> values from the current stream into a
 /// <see cref="Boolean"/> array. The <see cref="Boolean"/> values are available in the specified binary format.
 /// </summary>
 /// <param name="count">The number of <see cref="Boolean"/> values to read.</param>
 /// <param name="format">The binary format, in which the <see cref="Boolean"/> values will be read.</param>
 /// <returns>The <see cref="Boolean"/> array read from the current stream.</returns>
 public Boolean[] ReadBooleans(int count, BinaryBooleanFormat format)
 {
     Boolean[] values = new Boolean[count];
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = ReadBoolean(format);
     }
     return(values);
 }
Esempio n. 5
0
 /// <summary>
 /// Reads <see cref="Vector4Bool"/> instances from the current stream and returns them.
 /// </summary>
 /// <param name="self">The extended <see cref="BinaryDataReader"/>.</param>
 /// <param name="count">The number of instances to read.</param>
 /// <param name="format">The <see cref="BinaryBooleanFormat"/> in which values are stored.</param>
 /// <returns>The <see cref="Vector4Bool"/> instances.</returns>
 public static IList <Vector4Bool> ReadVector4Bools(this BinaryDataReader self, int count,
                                                    BinaryBooleanFormat format = BinaryBooleanFormat.NonZeroByte)
 {
     Vector4Bool[] values = new Vector4Bool[count];
     for (int i = 0; i < count; i++)
     {
         values[i] = self.ReadVector4Bool(format);
     }
     return(values);
 }
        /// <summary>
        /// Reads a <see cref="Boolean"/> value from the current stream. The <see cref="Boolean"/> is available in the
        /// specified binary format.
        /// </summary>
        /// <param name="format">The binary format, in which the <see cref="Boolean"/> will be read.</param>
        /// <returns>The <see cref="Boolean"/> read from the current stream.</returns>
        public Boolean ReadBoolean(BinaryBooleanFormat format)
        {
            switch (format)
            {
            case BinaryBooleanFormat.NonZeroByte:
                return(base.ReadBoolean());

            case BinaryBooleanFormat.NonZeroWord:
                return(ReadInt16() != 0);

            case BinaryBooleanFormat.NonZeroDword:
                return(ReadInt32() != 0);

            default:
                throw new ArgumentOutOfRangeException(nameof(format),
                                                      "The specified binary boolean format is invalid.");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Writes a <see cref="Boolean"/> value in the given format to the current stream, with 0 representing
        /// <c>false</c> and 1 representing <c>true</c>.
        /// </summary>
        /// <param name="value">The <see cref="Boolean"/> value to write.</param>
        /// <param name="format">The binary format in which the <see cref="Boolean"/> will be written.</param>
        public void Write(Boolean value, BinaryBooleanFormat format)
        {
            switch (format)
            {
            case BinaryBooleanFormat.NonZeroByte:
                base.Write(value);
                break;

            case BinaryBooleanFormat.NonZeroWord:
                Write(value ? (Int16)1 : (Int16)0);
                break;

            case BinaryBooleanFormat.NonZeroDword:
                Write(value ? 1 : 0);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(format),
                                                      "The specified binary boolean format is invalid.");
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Reads a <see cref="Vector4Bool"/> instance from the current stream and returns it.
 /// </summary>
 /// <param name="self">The extended <see cref="BinaryDataReader"/>.</param>
 /// <param name="format">The <see cref="BinaryBooleanFormat"/> in which values are stored.</param>
 /// <returns>The <see cref="Vector4Bool"/> instance.</returns>
 public static Vector4Bool ReadVector4Bool(this BinaryDataReader self,
                                           BinaryBooleanFormat format = BinaryBooleanFormat.NonZeroByte)
 {
     return(new Vector4Bool(self.ReadBoolean(format), self.ReadBoolean(format), self.ReadBoolean(format),
                            self.ReadBoolean(format)));
 }