/// <summary>
        /// Gets the next event of specified types from the file.
        /// </summary>
        /// <param name="streamDataTypes">The event types to retrieve.</param>
        /// <returns>The next XEFEvent if available; otherwise, null.</returns>
        public XEFEvent GetNextEvent(ICollection <Guid> streamDataTypes)
        {
            XEFEvent xefEvent = null;

            do
            {
                xefEvent = GetNextEvent();
            } while (xefEvent != null && !streamDataTypes.Contains(xefEvent.EventStreamDataTypeId));

            return(xefEvent);
        }
        private XEFStream ReadStreamDescription()
        {
            //
            //  Stream name
            //

            XEFEvent nameEvent = ReadDataEvent();

            // Extract useful data
            short streamIndex = BitConverter.ToInt16(nameEvent.TagData, DataConstants.STREAM_INDEX_OFFSET);
            short streamFlags = BitConverter.ToInt16(nameEvent.TagData, DataConstants.STREAM_FLAGS_OFFSET);
            bool  compressed  = (streamFlags & DataConstants.FLAG_COMPRESSED) == DataConstants.FLAG_COMPRESSED;

            byte[] guidBuf = new byte[DataConstants.STREAM_TYPID_SIZE];
            Array.Copy(nameEvent.TagData, DataConstants.STREAM_TYPID_OFFSET, guidBuf, 0, DataConstants.STREAM_TYPID_SIZE);

            Guid dataTypeId = new Guid(guidBuf);

            string dataTypeName = Encoding.Unicode.GetString(nameEvent.EventData, 0, DataConstants.STREAM_NAME_SIZE).TrimEnd('\0');
            short  tagSize      = BitConverter.ToInt16(nameEvent.EventData, DataConstants.STREAM_TAGSIZE_OFFSET);

            //
            //  Unknown compressed data
            //

            // If compressed, skip extra data (unknown purpose)
            if (compressed)
            {
                _reader.ReadBytes(DataConstants.ARC_STREAM_EXTRA_UNK_SIZE);
            }

            //
            //  Stream GUID
            //

            // Second event is considered a property event with stream index 0
            XEFEvent guidEvent = ReadDataEvent();

            Array.Copy(nameEvent.EventData, DataConstants.STREAM_SEMID_OFFSET, guidBuf, 0, DataConstants.STREAM_SEMID_SIZE);
            Guid semanticId = new Guid(guidBuf);

            // Create new stream
            return(new XEFStream(streamIndex, streamFlags, tagSize, dataTypeName, dataTypeId, semanticId));
        }
        /// <summary>
        /// Gets all events of specified types from the file.
        /// </summary>
        /// <param name="streamDataTypes">The event type to retrieve.</param>
        /// <returns>An IReadOnlyList of all the XEFEvents.</returns>
        public IReadOnlyList <XEFEvent> GetAllEvents(ICollection <Guid> streamDataTypes)
        {
            // Reset reader
            _reader.BaseStream.Position = _eventStartAddress;

            // Read all events into list
            List <XEFEvent> allEvents = new List <XEFEvent>();

            while (!EndOfStream)
            {
                XEFEvent xefEvent = GetNextEvent();
                if (xefEvent != null && streamDataTypes.Contains(xefEvent.EventStreamDataTypeId))
                {
                    allEvents.Add(xefEvent);
                }
            }

            return(allEvents);
        }
        /// <summary>
        /// Gets all events from the file.
        /// </summary>
        /// <returns>An IReadOnlyList of all the XEFEvents.</returns>
        public IReadOnlyList <XEFEvent> GetAllEvents()
        {
            // Reset reader
            _reader.BaseStream.Position = _eventStartAddress;

            // Read all events into list
            List <XEFEvent> allEvents = new List <XEFEvent>();

            while (!EndOfStream)
            {
                XEFEvent xefEvent = GetNextEvent();
                if (xefEvent != null)
                {
                    allEvents.Add(xefEvent);
                }
            }

            return(allEvents);
        }
Beispiel #5
0
 public void AddEvent(XEFEvent xefEvent)
 {
     // TODO Not storing events because it loads too much data into memory
     _eventsCount++;
 }