private object ReadWithFormatter() { string typeName = ReadPropertyName(); var t = TypeExtensions.GetTypeByAssemblyQualifiedName(typeName); IBinaryDataFormatter f; if (!BinaryDataFormatterService.Resolve(t, out f)) { throw new InvalidOperationException($"Can't read {typeName} from binary data, formatter not found"); } return(f.Read(t, this)); }
private BinaryDataWriter WriteWithFormatter(object value) { Type t = value.GetType(); if (!BinaryDataFormatterService.Resolve(t, out IBinaryDataFormatter f)) { throw new InvalidOperationException($"Can't write {t} as binary data, formatter not found"); } Write(ExportedDataTypes.serial); WritePropertyName(t.AssemblyQualifiedName); f.Write(this, value); return(this); }