Interface IStreamProvider
Interface for the DocumentStream to access the archive.
Namespace: SuperOffice.IO
Assembly: SoCore.dll
Syntax
public interface IStreamProvider
Properties
Length
Length (in bytes) of the document.
Declaration
long Length { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
BeginReadAsync(CancellationToken)
Start reading the document.
Declaration
Task BeginReadAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Read bytes from the document using the Read(long, byte[], int, int) method.
Call the EndRead method to specify that you are
finished reading the document.
BeginWriteAsync(CancellationToken)
Start writing the document file.
Declaration
Task BeginWriteAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Use the Write(long, byte[], int, int) method to write data to the file.
As data might be written to a temporary location, the EndWrite
will archive the document to the document archive.
EndReadAsync(CancellationToken)
Express that you are finished reading the file. If the file is read from a temporary location, it will be removed from it.
Declaration
Task EndReadAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
EndWriteAsync(CancellationToken)
Specify that the writing of the document is completed and that the document can be archived in the document archive.
Declaration
Task EndWriteAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Read(long, byte[], int, int)
Sync version of Read, eternally required by the double sync/async contracts of the Stream class
Declaration
int Read(long filePosition, byte[] buffer, int bufferStartPosition, int lenght)
Parameters
| Type | Name | Description |
|---|---|---|
| long | filePosition | |
| byte[] | buffer | |
| int | bufferStartPosition | |
| int | lenght |
Returns
| Type | Description |
|---|---|
| int |
ReadAsync(long, byte[], int, int, CancellationToken)
Read data from the document
Declaration
Task<int> ReadAsync(long filePosition, byte[] buffer, int bufferStartPosition, int lenght, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| long | filePosition | Position in the file to start reading from. |
| byte[] | buffer | Buffer to put the data read. |
| int | bufferStartPosition | Position in buffer to start filling it. |
| int | lenght | Number of bytes to read from the file. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<int> | Number of bytes actually read from the file. This should only be less then the file when the end of file is reached. |
Remarks
BeginRead must be called before this method. It is not requred that BeginRead is called within the scope of this method. It is required that it is called on bahalf of the same user and on the same document and that either this method or BeginRead is called during the last time period specified in the configuration. Default time period is 24 hours.
Write(long, byte[], int, int)
Sync version of Write, eternally required by the double sync/async contracts of the Stream class
Declaration
void Write(long filePosition, byte[] buffer, int bufferStartPosition, int lenght)
Parameters
| Type | Name | Description |
|---|---|---|
| long | filePosition | |
| byte[] | buffer | |
| int | bufferStartPosition | |
| int | lenght |
WriteAsync(long, byte[], int, int, CancellationToken)
Write a block of data to a file.
Declaration
Task WriteAsync(long filePosition, byte[] buffer, int bufferStartPosition, int lenght, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| long | filePosition | Position in the file to start writing |
| byte[] | buffer | Buffer to write |
| int | bufferStartPosition | Position in the buffer to start writing from. |
| int | lenght | Number of bytes to write from the buffer. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
BeginWrite must be called before this method. It is not requred that BeginWrite is called within the scope of this method. It is required that it is called on bahalf of the same user and on the same document and that either this method or BeginWrite is called during the last time period specified in the configuration. Default time period is 24 hours.