Пример #1
0
        /// <summary>
        /// Reads the next short from the stream, and checks if it equals 'value'.
        /// </summary>
        /// <param name="value">The value to compare against the next short 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 short is the same as the specified value</returns>
        public bool Assert(short value, ushort objectID, string objectName, string objectType,
                           string precedingProperty)
        {
            long Location = _stream.Position;

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

            short Value = ByteConversion.ToShort(temp, 0);

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

                InvalidMarkerEvent(null, Args);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Reads the next byte from the stream, and checks if it equals 'value'.
        /// </summary>
        /// <param name="value">The value to compare against the next byte 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(byte value, ushort objectID, string objectName, string objectType,
                           string precedingProperty)
        {
            long Location = _stream.Position;

            Byte b = (byte)_stream.ReadByte();

            if (b != value)
            {
                InvalidMarkerEventArgs Args = new InvalidMarkerEventArgs(Location,
                                                                         objectID,
                                                                         objectName,
                                                                         objectType,
                                                                         precedingProperty,
                                                                         value,
                                                                         b);
                InvalidMarkerEvent(null, Args);
            }

            return(true);
        }