Beispiel #1
0
        /// <summary>
        /// Constructs InstanceLogger with given file.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="mode"></param>
        public InstanceLogger(string filename, FileMode mode = FileMode.OpenOrCreate)
        {
            log        = new FileLog(filename, mode);
            IsTempFile = false;
            int count = log.GetChannelCount();

            using (var reader = log.ReaderPool.Get())
            {
                channels.AddRange(reader.ReadChannelsData(1, count));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads channel data
        /// </summary>
        /// <param name="id">1-based channel id</param>
        /// <returns>channel</returns>
        public IChannel ReadChannelData(int id)
        {
            if (log.GetChannelCount() >= id)
            {
                int off;
                var hint = getChannelTableHintByID(id, out off);

                lock (streamLock)
                {
                    var initialPos = stream.Position;
                    // move stream position to the correct channel pointer
                    stream.Position += off * sizeof(long);
                    // move the stream position to channel data
                    var ret = readChannelDataByHint(binReader.ReadInt64());
                    stream.Position = initialPos;
                    return(ret);
                }
            }
            return(null);
        }