sealed public override object Read(CompactBinaryReader reader) { int cookie = reader.ReadInt32(); object graph = reader.Context.GetObject(cookie); if (graph == null) { bool bKnown = false; graph = Instantiate(reader); if (graph != null) { reader.Context.RememberObject(graph, false); bKnown = true; } if (VersionCompatible) { long startPosition = 0; int dataLength = 0; long endPosition = 0; startPosition = reader.BaseReader.BaseStream.Position; dataLength = reader.ReadInt32(); reader.BeginCurrentObjectDeserialization(startPosition + dataLength); graph = ReadDirect(reader, graph); reader.EndCurrentObjectDeserialization(); if (dataLength != -1 && (endPosition - startPosition) < dataLength) { endPosition = reader.BaseReader.BaseStream.Position; reader.SkipBytes((int)(dataLength - (endPosition - startPosition))); } } else { reader.BeginCurrentObjectDeserialization(reader.BaseReader.BaseStream.Length); graph = ReadDirect(reader, graph); reader.EndCurrentObjectDeserialization(); } if (!bKnown) { reader.Context.RememberObject(graph, false); } } return(graph); }