public object Read(object value, ProtoReader source) { ProtoReader.ExpectRoot(source); if (_protoCompatibility) { return(_serializer.Read(value, source)); } int typeKey; object obj; int expectedRefKey; var rootToken = ProtoReader.StartSubItem(source); int formatVersion = source.ReadFieldHeader(); if (formatVersion != CurrentFormatVersion) { throw new ProtoException("Wrong format version, required " + CurrentFormatVersion + " but actual " + formatVersion); } var r = _serializer.Read(value, source); while (ProtoReader.TryGetNextLateReference(out typeKey, out obj, out expectedRefKey, source)) { int actualRefKey; do { actualRefKey = source.ReadFieldHeader() - 1; if (actualRefKey != expectedRefKey) { if (actualRefKey <= -1) { throw new ProtoException("Expected field for late reference"); } // should go only up if (actualRefKey > expectedRefKey) { throw new ProtoException("Mismatched order of late reference objects"); } source.SkipField(); // refKey < num } } while (actualRefKey < expectedRefKey); object lateObj = ProtoReader.ReadObject(obj, typeKey, source); if (!ReferenceEquals(lateObj, obj)) { throw new ProtoException("Late reference changed during deserializing"); } } ProtoReader.EndSubItem(rootToken, true, source); return(r); }
public object Read(object value, ProtoReader source) { if (source.ReadFieldHeader() != _number) { throw new ProtoException("Expected tag " + _number); } return(_serializer.Read(value, source)); }
public object Read(object value, ProtoReader source) { // convert the incoming value object[] args = { value }; value = toTail.Invoke(null, args); // invoke the tail and convert the outgoing value args[0] = rootTail.Read(value, source); return(fromTail.Invoke(null, args)); }
public object Read(object value, ProtoReader source) { object[] array = new object[1] { value }; value = toTail.Invoke(null, array); array[0] = rootTail.Read(value, source); return(fromTail.Invoke(null, array)); }
public object Read(ref ProtoReader.State state, object value) { // convert the incoming value object[] args = { value }; value = toTail.Invoke(null, args); // invoke the tail and convert the outgoing value args[0] = rootTail.Read(ref state, value); return(fromTail.Invoke(null, args)); }
public object Read(object value, ProtoReader source) { int reservedTrap = -1; if (!Helpers.IsValueType(ExpectedType)) { reservedTrap = ProtoReader.ReserveNoteObject(source); } // convert the incoming value object[] args = { value }; value = _toTail.Invoke(null, args); // don't note, references are not to surrogate but to the final object // invoke the tail and convert the outgoing value args[0] = _rootTail.Read(value, source); var r = _fromTail.Invoke(null, args); if (!Helpers.IsValueType(ExpectedType)) { ProtoReader.NoteReservedTrappedObject(reservedTrap, r, source); } return(r); }