Show / Hide Table of Contents

Class ShieldedStream

Proxy stream that prevents the underlying stream from being closed.

Inheritance
object
MarshalByRefObject
Stream
ShieldedStream
Implements
IAsyncDisposable
IDisposable
Inherited Members
Stream.Null
Stream.CopyTo(Stream)
Stream.CopyTo(Stream, int)
Stream.CopyToAsync(Stream)
Stream.CopyToAsync(Stream, int)
Stream.CopyToAsync(Stream, int, CancellationToken)
Stream.CopyToAsync(Stream, CancellationToken)
Stream.CreateWaitHandle()
Stream.Dispose()
Stream.Dispose(bool)
Stream.DisposeAsync()
Stream.FlushAsync()
Stream.FlushAsync(CancellationToken)
Stream.ObjectInvariant()
Stream.Read(Span<byte>)
Stream.ReadAsync(byte[], int, int)
Stream.ReadAsync(byte[], int, int, CancellationToken)
Stream.ReadAsync(Memory<byte>, CancellationToken)
Stream.Synchronized(Stream)
Stream.ValidateBufferArguments(byte[], int, int)
Stream.ValidateCopyToArguments(Stream, int)
Stream.Write(ReadOnlySpan<byte>)
Stream.WriteAsync(byte[], int, int)
Stream.WriteAsync(byte[], int, int, CancellationToken)
Stream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
Stream.CanTimeout
Stream.ReadTimeout
Stream.WriteTimeout
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
MarshalByRefObject.MemberwiseClone(bool)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public class ShieldedStream : Stream, IAsyncDisposable, IDisposable

Constructors

ShieldedStream(Stream)

Constructs a wrapper around underlying stream that should be shielded.

Declaration
public ShieldedStream(Stream stream)
Parameters
Type Name Description
Stream stream

Underlying stream.

Properties

CanRead

Gets a value indicating whether the current stream supports reading.

Declaration
public override bool CanRead { get; }
Property Value
Type Description
bool

true if the stream supports reading; otherwise, false.

Overrides
Stream.CanRead

CanSeek

Gets a value indicating whether the current stream supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
bool

true if the stream supports seeking; otherwise, false.

Overrides
Stream.CanSeek

CanWrite

Gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
bool

true if the stream supports writing; otherwise, false.

Overrides
Stream.CanWrite

Length

Gets the length in bytes of the stream.

Declaration
public override long Length { get; }
Property Value
Type Description
long

A long value representing the length of the stream in bytes.

Overrides
Stream.Length

Position

Gets or sets the position within the current stream.

Declaration
public override long Position { get; set; }
Property Value
Type Description
long

The current position within the stream.

Overrides
Stream.Position

Methods

BeginRead(byte[], int, int, AsyncCallback, object)

Begins an asynchronous read operation.

Declaration
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type Name Description
byte[] buffer

The buffer to read the data into.

int offset

The byte offset in buffer at which to begin writing data read from the stream.

int count

The maximum number of bytes to read.

AsyncCallback callback

An optional asynchronous callback, to be called when the read is complete.

object state

A user-provided object that distinguishes this particular asynchronous read request from other requests.

Returns
Type Description
IAsyncResult

An IAsyncResult that represents the asynchronous read, which could still be pending.

Overrides
Stream.BeginRead(byte[], int, int, AsyncCallback, object)

BeginWrite(byte[], int, int, AsyncCallback, object)

Begins an asynchronous write operation.

Declaration
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type Name Description
byte[] buffer

The buffer to write data from.

int offset

The byte offset in buffer from which to begin writing.

int count

The maximum number of bytes to write.

AsyncCallback callback

An optional asynchronous callback, to be called when the write is complete.

object state

A user-provided object that distinguishes this particular asynchronous write request from other requests.

Returns
Type Description
IAsyncResult

An IAsyncResult that represents the asynchronous write, which could still be pending.

Overrides
Stream.BeginWrite(byte[], int, int, AsyncCallback, object)

Close()

Overriden method that prevents underlying stream from being closed.

Declaration
public override void Close()
Overrides
Stream.Close()

EndRead(IAsyncResult)

Waits for the pending asynchronous read to complete.

Declaration
public override int EndRead(IAsyncResult asyncResult)
Parameters
Type Name Description
IAsyncResult asyncResult

The reference to the pending asynchronous request to finish.

Returns
Type Description
int

The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available.

Overrides
Stream.EndRead(IAsyncResult)

EndWrite(IAsyncResult)

Ends an asynchronous write operation.

Declaration
public override void EndWrite(IAsyncResult asyncResult)
Parameters
Type Name Description
IAsyncResult asyncResult

A reference to the outstanding asynchronous I/O request.

Overrides
Stream.EndWrite(IAsyncResult)

Flush()

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Declaration
public override void Flush()
Overrides
Stream.Flush()

Read(byte[], int, int)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type Name Description
byte[] buffer

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

int offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

int count

The maximum number of bytes to be read from the current stream.

Returns
Type Description
int

The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

Overrides
Stream.Read(byte[], int, int)

ReadByte()

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Declaration
public override int ReadByte()
Returns
Type Description
int

The unsigned byte cast to an Int32, or -1 if at the end of the stream.

Overrides
Stream.ReadByte()

Seek(long, SeekOrigin)

Sets the position within the current stream.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
long offset

A byte offset relative to the origin parameter.

SeekOrigin origin

A value of type SeekOrigin indicating the reference point used to obtain the new position.

Returns
Type Description
long

The new position within the current stream.

Overrides
Stream.Seek(long, SeekOrigin)

SetLength(long)

Sets the length of the current stream.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
long value

The desired length of the current stream in bytes.

Overrides
Stream.SetLength(long)

Write(byte[], int, int)

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
byte[] buffer

An array of bytes. This method copies count bytes from buffer to the current stream.

int offset

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

int count

The number of bytes to be written to the current stream.

Overrides
Stream.Write(byte[], int, int)

WriteByte(byte)

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Declaration
public override void WriteByte(byte value)
Parameters
Type Name Description
byte value

The byte to write to the stream.

Overrides
Stream.WriteByte(byte)

Implements

IAsyncDisposable
IDisposable
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.