Esempio n. 1
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);
        }