static private ThrowUnexpectedEndOfStream ( Unpacker unpacker ) : void | ||
unpacker | Unpacker | |
Результат | void |
/// <summary> /// Deserialize object from the <see cref="Stream"/>. /// </summary> /// <param name="stream">Source <see cref="Stream"/>.</param> /// <returns>Deserialized object.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="stream"/> is <c>null</c>. /// </exception> public object Unpack(Stream stream) { // Unpacker does not have finalizer, so just avoiding unpacker disposing prevents stream closing. var unpacker = Unpacker.Create(stream); if (!unpacker.Read()) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } return(this.UnpackFrom(unpacker)); }
/// <summary> /// Deserialize object from the <see cref="Stream"/>. /// </summary> /// <param name="source"><see cref="MessagePackSerializer"/> object.</param> /// <param name="stream">Source <see cref="Stream"/>.</param> /// <returns>Deserialized object.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="source"/> is <c>null</c>. /// Or <paramref name="stream"/> is <c>null</c>. /// </exception> /// <exception cref="System.Runtime.Serialization.SerializationException"> /// Failed to deserialize from <paramref name="stream"/>. /// </exception> public static object Unpack(this MessagePackSerializer source, Stream stream) { if (source == null) { throw new ArgumentNullException("source"); } if (stream == null) { throw new ArgumentNullException("stream"); } // Unpacker does not have finalizer, so just avoiding unpacker disposing prevents stream closing. var unpacker = Unpacker.Create(stream); if (!unpacker.Read()) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } return(source.UnpackFrom(unpacker)); }