Class ProviderStream
Stream for reading from and writing to the document archive.
Implements
Inherited Members
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
CanSeek
Does the stream support seeking?
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
CanWrite
Does the stream support writing?
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Length
Stream for reading from and writing to the document archive.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
long |
Overrides
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
Methods
Close()
Close the stream. Note that this method has no CloseAsync equivalent in the base class.
Declaration
public override void Close()
Overrides
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
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
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
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
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
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
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
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 |