Example #1
0
		public override void Load(PrimitiveReader reader)
		{
			var present = reader.ReadBoolean();
			if(present)
			{
				Placeholder = reader.ReadString();
			}
		}
Example #2
0
        public void Load(PrimitiveReader reader)
        {
            Id = reader.ReadUInt64();
            Message = reader.ReadString();
            SourceId = reader.ReadInt32();
            ThreadId = reader.ReadInt32();
            Time = new DateTime(reader.ReadInt64());
            numericLogLevel = reader.ReadInt32();

            if(ThreadId == -1)
            {
                ThreadId = null;
            }
        }
Example #3
0
 public void Load(PrimitiveReader reader)
 {
     // checking magic
     var magic = reader.ReadUInt32();
     if(magic != Magic)
     {
         throw new InvalidOperationException("Memory: Cannot resume state from stream: Invalid magic.");
     }
     SegmentSize = reader.ReadInt32();
     size = reader.ReadUInt32();
     if(emptyCtorUsed)
     {
         Init();
     }
     var realSegmentsCount = 0;
     for(var i = 0; i < segments.Length; i++)
     {
         var isTouched = reader.ReadBoolean();
         if(!isTouched)
         {
             continue;
         }
         var compressedSegmentSize = reader.ReadInt32();
         var compressedBuffer = reader.ReadBytes(compressedSegmentSize);
         TouchSegment(i);
         realSegmentsCount++;
         LZ4Codec.Decode64(compressedBuffer, segments[i], SegmentSize);
     }
     this.NoisyLog(string.Format("{0} segments loaded from stream, of which {1} had content.", segments.Length, realSegmentsCount));
 }
Example #4
0
        internal static void LoadAndVerifySpeciallySerializableAndVerify(ISpeciallySerializable obj, PrimitiveReader reader)
        {
            var beforePosition = reader.Position;

            obj.Load(reader);
            var afterPosition    = reader.Position;
            var serializedLength = reader.ReadInt64();

            if (serializedLength + beforePosition != afterPosition)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Stream corruption by '{0}', incorrent magic {1} when {2} expected.", obj.GetType(), serializedLength, afterPosition - beforePosition));
            }
        }
Example #5
0
 private static bool TryDeserializeEntry(PrimitiveReader reader, out LogEntry entry)
 {
     var localEntry = (LogEntry)FormatterServices.GetUninitializedObject(typeof(LogEntry));
     try 
     {
         localEntry.Load(reader);
         entry = localEntry;
         return true;
     } 
     catch (EndOfStreamException)
     {
         // intentionally left blank
     }
     entry = null;
     return false;
 }
Example #6
0
            public IEnumerable<LogEntry> ReadDataFromInactiveBuffer(ProgressMonitor progressMonitor)
            {
                var monitoredAction = progressMonitor.Start("Reading log entries...", progressable: true);
                var lastUpdate = CustomDateTime.Now;
                switchSync.WaitOne();
                try
                {
                    var bufferPath = Path.Combine(TemporaryFilesManager.Instance.EmulatorTemporaryPath, string.Format("{0}.{1}", BUFFER_FILE, (currentBuffer + 1) % 2));
                    using(var inactiveBuffer = File.OpenRead(bufferPath))
                    {
                        var primitiveReader = new PrimitiveReader(inactiveBuffer, false);
                        var stopwatch = new Stopwatch();
                        stopwatch.Start();
                        var entriesCount = 0;

                        LogEntry entry;
                        while(TryDeserializeEntry(primitiveReader, out entry))
                        {
                            if(stopwatch.Elapsed > TimeSpan.FromMilliseconds(50))
                            {
                                monitoredAction.UpdateProgress((int)(100.0 * inactiveBuffer.Position / inactiveBuffer.Length),
                                    string.Format("Reading log entries ({0})...", Interlocked.Add(ref entriesCount, 0)));
                                stopwatch.Restart();
                            }
                            yield return entry;
                            Interlocked.Increment(ref entriesCount);
                        }

                        monitoredAction.UpdateProgress(100);
                    }
                }
                finally
                {
                    switchSync.Release();
                }
            }
Example #7
0
        public virtual void Load(PrimitiveReader reader)
        {
			
        }
Example #8
0
 public void ReadFrom(PrimitiveReader reader)
 {
     Name    = reader.ReadString();
     TypeAQN = reader.ReadString();
 }