Example #1
0
        /// <summary>
        /// Reads the next int from the stream, and checks if it equals 'value'.
        /// </summary>
        /// <param name="value">The value to compare against the next int from the stream</param>
        /// <param name="objectID">The ID of the marker (if known)</param>
        /// <param name="objectName">The name of the object being affected</param>
        /// <param name="objectType">The type of object (if known)</param>
        /// <param name="precedingProperty">The property immediately before the invalid marker</param>
        /// <returns>true or false, depending on whether the read byte is the same as the specified value</returns>
        public bool Assert(int value, ushort objectID, string objectName, string objectType,
                           string precedingProperty)
        {
            long Location = _stream.Position;

            byte[] temp = new byte[INTLENGTH];
            _stream.Read(temp, 0, INTLENGTH);

            int Value = ByteConversion.ToInt(temp, 0);

            if (Value != value)
            {
                InvalidMarkerEventArgs Args = new InvalidMarkerEventArgs(Location,
                                                                         objectID,
                                                                         objectName,
                                                                         objectType,
                                                                         precedingProperty,
                                                                         value,
                                                                         Value);

                InvalidMarkerEvent(null, Args);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Reads a int from the stream, and advances the index accordingly.
        /// </summary>
        /// <returns>the next 4 bytes from the stream cast as a int</returns>
        public int ReadInt()
        {
            byte[] temp = new byte[INTLENGTH];
            _stream.Read(temp, 0, INTLENGTH);

            return(ByteConversion.ToInt(temp, 0));
        }
Example #3
0
        /// <summary>
        /// Reads the next int from the stream, and checks if it equals 'value'.
        /// </summary>
        /// <param name="value">The value to compare against the next int from the stream</param>
        /// <param name="failmessage">The error message to be thrown if the int does not equal value</param>
        /// <returns>true or false, depending on whether the read byte is the same as the specified value</returns>
        public bool Assert(int value, string failmessage)
        {
            byte[] temp = new byte[INTLENGTH];
            _stream.Read(temp, 0, INTLENGTH);

            if (ByteConversion.ToInt(temp, 0) != value)
            {
                throw new AssertFailedException(failmessage);
            }

            return(true);
        }