예제 #1
0
        internal virtual void DeCompress(CompressedDataItem16 item, DateTime baseTime)
        {
            this.ProcessId       = item.Pid;
            this.ThreadId        = item.Tid;
            this.ActivityIdIndex = item.Aid;
            this.FileIndex       = item.FileIndex;
            this.Level           = LevelMapping[item.Level];

            this.Time       = baseTime.AddSeconds(item.TimeOffsetSeconds);
            this.TemplateId = item.TemplateId;
        }
예제 #2
0
        internal virtual bool Compress(DateTime baseTime, out CompressedDataItem16 item)
        {
            item = new CompressedDataItem16();

            if ((this.ProcessId >> CompressedDataItem16.PidSize) > 0)
            {
                return(false);
            }
            item.Pid = this.ProcessId;
            if ((this.ThreadId >> CompressedDataItem16.TidSize) > 0)
            {
                return(false);
            }
            item.Tid = this.ThreadId;
            if ((this.ActivityIdIndex >> CompressedDataItem16.AidSize) > 0)
            {
                return(false);
            }
            item.Aid = this.ActivityIdIndex;
            if ((this.FileIndex >> CompressedDataItem16.FileIndexSize) > 0)
            {
                return(false);
            }
            item.FileIndex = this.FileIndex;
            item.Level     = LevelReverseMapping[(int)this.Level];

            var timeDiff = (int)(this.Time - baseTime).TotalSeconds;

            if ((timeDiff >> CompressedDataItem16.TimeSize) > 0)
            {
                return(false);
            }
            item.TimeOffsetSeconds = timeDiff;

            // caution with the bug, >> 32 means nothing.
            if (CompressedDataItem16.TemplateIdSize < 32 && (this.TemplateId >> CompressedDataItem16.TemplateIdSize) > 0)
            {
                return(false);
            }
            item.TemplateId = (ushort)this.TemplateId;

            item.State = CompressState.Compressed16;

            return(true);
        }