/// <summary> /// Deserializes a <see cref="Stream"/> to the specified <paramref name="instance"/>. /// </summary> /// <param name="instance">The instance that the <paramref name="stream"/> will be deserialized to.</param> /// <param name="stream">The <see cref="Stream"/> containing the data to deserialize.</param> /// <exception cref="ArgumentNullException"> thrown if the <paramref name="instance"/> or <paramref name="stream"/> is <c>Null</c>.</exception> public static void Deserialize(this IBinarySerializable instance, Stream stream) { if (instance.IsNull()) { throw new ArgumentNullException("instance"); } if (stream.IsNull()) { throw new ArgumentNullException("stream"); } Formatters.Binary.BinaryFormatter formatter = new Formatters.Binary.BinaryFormatter(); formatter.Deserialize(stream).CopyTo(instance); }