Пример #1
0
 /// <summary>
 /// Deserializes an array of RawGffFields from a stream.
 /// </summary>
 /// <param name="s">The stream</param>
 /// <param name="count">The number of fields to deserialize</param>
 /// <returns>The deserialized array</returns>
 public static RawGffField[] Deserialize(Stream s, int count)
 {
     RawGffField[] fields = new RawGffField[count];
     for (int i = 0; i < count; i++)
         fields[i] = new RawGffField(s);
     return fields;
 }
Пример #2
0
 /// <summary>
 ///  Serializes an array of RawGffFields to a stream.
 /// </summary>
 /// <param name="s">The stream</param>
 /// <param name="fields">The array of fields to serialize</param>
 public static void Serialize(Stream s, RawGffField[] fields)
 {
     foreach (RawGffField gff in fields)
         gff.Serialize(s);
 }
Пример #3
0
        /// <summary>
        /// Adds a new field to the end of the structure stream.  This method
        /// is only valid for write access raw data.
        /// </summary>
        /// <param name="rawStruct">The field to add</param>
        /// <returns>The index of the addes field, it is always added to the
        /// end of the list</returns>
        public uint AddField(RawGffField rawField)
        {
            if (FileAccess.Write != access) throw new InvalidOperationException();

            // Seek to the end of the stream and add the struct.
            fieldsStream.Seek(0, SeekOrigin.End);
            rawField.Serialize(fieldsStream);

            // Count the number of structs in the stream and return the index of
            // the last one, which is the one we just added.
            int count = (int) fieldsStream.Length / Marshal.SizeOf(typeof(RawGffField));
            return (uint) (count - 1);
        }