Show / Hide Table of Contents

Class ProviderStream

Stream for reading from and writing to the document archive.

Inheritance
object
MarshalByRefObject
Stream
ProviderStream
Implements
IDisposable
Inherited Members
Stream.Null
Stream.CopyToAsync(Stream)
Stream.CopyToAsync(Stream, int)
Stream.CopyToAsync(Stream, CancellationToken)
Stream.CopyToAsync(Stream, int, CancellationToken)
Stream.CopyTo(Stream)
Stream.CopyTo(Stream, int)
Stream.Dispose(bool)
Stream.FlushAsync()
Stream.CreateWaitHandle()
Stream.BeginRead(byte[], int, int, AsyncCallback, object)
Stream.EndRead(IAsyncResult)
Stream.ReadAsync(byte[], int, int)
Stream.ReadAsync(Memory<byte>, CancellationToken)
Stream.BeginWrite(byte[], int, int, AsyncCallback, object)
Stream.EndWrite(IAsyncResult)
Stream.WriteAsync(byte[], int, int)
Stream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
Stream.Read(Span<byte>)
Stream.ReadByte()
Stream.Write(ReadOnlySpan<byte>)
Stream.WriteByte(byte)
Stream.Synchronized(Stream)
Stream.ObjectInvariant()
Stream.CanTimeout
Stream.ReadTimeout
Stream.WriteTimeout
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
MarshalByRefObject.MemberwiseClone(bool)
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.IO
Assembly: SoCore.dll
Syntax
public class ProviderStream : Stream, IDisposable

Properties

CanRead

Does the stream support reading?

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

CanSeek

Does the stream support seeking?

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

CanWrite

Does the stream support writing?

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

Length

Stream for reading from and writing to the document archive.

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

Position

Current position in stream buffer, as seen by caller (not internal chunk buffer position)

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

Methods

Close()

Close the stream. Note that this method has no CloseAsync equivalent in the base class.

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

I think we're trapped into using SafeBlock here, since the base class does not support async Close. Anyway, we shouldn't even be here: https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.close?view=net-8.0#notes-to-inheritors On the other hand, NET Framework does not have a DisposeAsync so we'd end up with a SafeBlock here anyway...
As Microsoft says about the Dispose method on Stream:
Place all cleanup logic for your stream object in Dispose(Boolean). Do not override Close(). Note that because of backward compatibility requirements, this method's implementation differs from the recommended guidance for the Dispose pattern. This method calls Close(), which then calls Dispose(Boolean).
We do not respect this advice, but this code is super-old and we're not going to change it now.

Dispose()

Dispose of the document stream

Declaration
public void Dispose()

Flush()

Stream for reading from and writing to the document archive.

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

FlushAsync(CancellationToken)

Stream for reading from and writing to the document archive.

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public override Task FlushAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task
Overrides
Stream.FlushAsync(CancellationToken)

GetProviderStreamAsync(IStreamProvider, AccessMode, CancellationToken)

Get a new instance of the ProviderStream

Declaration
public static Task<ProviderStream> GetProviderStreamAsync(IStreamProvider provider, ProviderStream.AccessMode accessMode, CancellationToken cancellationToken)
Parameters
Type Name Description
IStreamProvider provider

Data source for the DocumentStream.

ProviderStream.AccessMode accessMode

Mode in which the DocumentStreamis accessed.

CancellationToken cancellationToken
Returns
Type Description
Task<ProviderStream>

New instance of the DocumentStream.

Read(byte[], int, int)

Read a block of bytes from a stream, and insert them into the given position in the callers buffer array

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

Destination buffer

int offsetIntoDestination

Where to start in the destination

int count

Number of bytes to read

Returns
Type Description
int

Number of bytes actually read

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

Note that the actual remote stream or file may be read using other chunk sizes than what is use in the incoming 'count' parameter. The Position property will report the position as seen by the caller, not the position as read from the file.

ReadAsync(byte[], int, int, CancellationToken)

Read a block of bytes from a stream, and insert them into the given position in the callers buffer array

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public override Task<int> ReadAsync(byte[] buffer, int offsetIntoDestination, int count, CancellationToken cancellationToken)
Parameters
Type Name Description
byte[] buffer

Destination buffer

int offsetIntoDestination

Where to start in the destination

int count

Number of bytes to read

CancellationToken cancellationToken
Returns
Type Description
Task<int>

Number of bytes actually read

Overrides
Stream.ReadAsync(byte[], int, int, CancellationToken)
Remarks

Note that the actual remote stream or file may be read using other chunk sizes than what is use in the incoming 'count' parameter. The Position property will report the position as seen by the caller, not the position as read from the file.

Seek(long, SeekOrigin)

Stream for reading from and writing to the document archive.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
long offset
SeekOrigin origin
Returns
Type Description
long
Overrides
Stream.Seek(long, SeekOrigin)

SetLength(long)

Stream for reading from and writing to the document archive.

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

Write(byte[], int, int)

Write a chunk of bytes to a stream, potentially triggering a write to the underlying file or remote stream

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

Source buffer containing data

int sourceOffset

Where to start getting data from the source buffer

int count

Number of bytes to get from offset

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

WriteAsync(byte[], int, int, CancellationToken)

Write a chunk of bytes to a stream, potentially triggering a write to the underlying file or remote stream

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public override Task WriteAsync(byte[] buffer, int sourceOffset, int count, CancellationToken cancellationToken)
Parameters
Type Name Description
byte[] buffer

Source buffer containing data

int sourceOffset

Where to start getting data from the source buffer

int count

Number of bytes to get from offset

CancellationToken cancellationToken
Returns
Type Description
Task
Overrides
Stream.WriteAsync(byte[], int, int, CancellationToken)

Implements

IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
StreamExtensions.CopyToNewStream(Stream)
StreamExtensions.CopyToNewStreamInChunks(Stream)
StreamExtensions.ReadReliably(Stream, long, int)
StreamExtensions.ToByteArray(Stream, int)
StreamExtensions.WriteInChunksTo(Stream, Stream)
ImageUtilities.GetThumbnailImage(Stream, int, int)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top