Redigera

Dela via


MetadataReaderProvider.FromMetadataStream Method

Definition

Creates a provider for a stream of the specified size beginning at its current position.

public static System.Reflection.Metadata.MetadataReaderProvider FromMetadataStream (System.IO.Stream stream, System.Reflection.Metadata.MetadataStreamOptions options = System.Reflection.Metadata.MetadataStreamOptions.Default, int size = 0);
static member FromMetadataStream : System.IO.Stream * System.Reflection.Metadata.MetadataStreamOptions * int -> System.Reflection.Metadata.MetadataReaderProvider
Public Shared Function FromMetadataStream (stream As Stream, Optional options As MetadataStreamOptions = System.Reflection.Metadata.MetadataStreamOptions.Default, Optional size As Integer = 0) As MetadataReaderProvider

Parameters

stream
Stream

A Stream instance.

options
MetadataStreamOptions

Options specifying how sections of the image are read from the stream.

size
Int32

Size of the metadata blob in the stream. If not specified, the metadata blob is assumed to span to the end of the stream.

Returns

The new provider.

Exceptions

stream is null.

stream doesn't support read and seek operations.

Size is negative or extends past the end of the stream.

Error reading from the stream (only when PrefetchMetadata is specified).

Remarks

Unless MetadataStreamOptions.LeaveOpen is specified, ownership of the stream is transferred to the MetadataReaderProvider upon successful argument validation. It will be disposed by the MetadataReaderProvider, and the caller must not manipulate it.

Unless MetadataStreamOptions.PrefetchMetadata is specified, no data is read from the stream during construction of the MetadataReaderProvider. Furthermore, the stream must not be manipulated by caller while the MetadataReaderProvider is alive and undisposed.

If MetadataStreamOptions.PrefetchMetadata, the MetadataReaderProvider will have read all of the data requested during construction. As such, if MetadataStreamOptions.LeaveOpen is also specified, the caller retains full ownership of the stream and is assured that it will not be manipulated by the MetadataReaderProvider after construction.

Applies to