public object Deserialize(BinaryReader reader) {
if (reader == null)
throw new ArgumentNullException("reader");
var graphType = ReadType(reader);
if (graphType == null)
throw new InvalidOperationException("No type found in the graph stream");
#if PCL
if (!graphType.GetTypeInfo().IsDefined(typeof(SerializableAttribute)))
#else
if (!Attribute.IsDefined(graphType, typeof (SerializableAttribute)))
#endif
throw new ArgumentException(String.Format("The type '{0}' is not marked as serializable.", graphType));
#if PCL
if (graphType.IsAssignableTo(typeof(ISerializable)))
#else
if (typeof (ISerializable).IsAssignableFrom(graphType))
#endif
return CustomDeserialize(reader, graphType);
return DeserializeType(reader, graphType);
}