Class RandomAccessStreamDataProvider

An implementation of IDataProvider that wraps a Windows.Storage.Streams.IRandomAccessStream.

Inheritance
System.Object
RandomAccessStreamDataProvider
Implements
Namespace: PSPDFKitFoundation.Data
Assembly: PSPDFKitFoundation.dll
Syntax
public sealed class RandomAccessStreamDataProvider : IDataProvider

Constructors

RandomAccessStreamDataProvider(IRandomAccessStream)

Constructs a RandomAccessStreamDataProvider from an Windows.Storage.Streams.IRandomAccessStream.

Declaration
public RandomAccessStreamDataProvider(IRandomAccessStream stream)
Parameters
Type Name Description
Windows.Storage.Streams.IRandomAccessStream stream

The Windows.Storage.Streams.IRandomAccessStream that provides the data.

RandomAccessStreamDataProvider(IRandomAccessStream, String)

Constructs a RandomAccessStreamDataProvider from an Windows.Storage.Streams.IRandomAccessStream.
A stable hash code will be created from the string passed in, helpful for persisting the same document id through application restarts and document changes.

Declaration
public RandomAccessStreamDataProvider(IRandomAccessStream stream, string hashString)
Parameters
Type Name Description
Windows.Storage.Streams.IRandomAccessStream stream

The Windows.Storage.Streams.IRandomAccessStream that provides the data.

System.String hashString

A string (usually an id or file name) used to identify the document persistently.

Properties

Size

Returns the size of the data.

Declaration
public ulong Size { get; }
Property Value
Type Description
System.UInt64

SupportsWriting

Specifies whether a write can be attempted using ReplaceWithDataSinkAsync(IDataSink).

Declaration
public bool SupportsWriting { get; }
Property Value
Type Description
System.Boolean

Uid

Returns a Uid that enables you to uniquely identify this data provider.
The Uid for the same provider might change between application restarts.
For persisting it, you must either implement your own mechanism, or use the RandomAccessStreamDataProvider(IRandomAccessStream, String) constructor to pin the hashCode to a persistent id representing the document.

Declaration
public string Uid { get; set; }
Property Value
Type Description
System.String

Methods

CreateDataSink(DataSinkOption)

This method creates a data sink for your data provider with the given DataSinkOption. PSPDFKit will write all the appropriate data into it and pass it to ReplaceWithDataSinkAsync(IDataSink) when appropriate.

Declaration
public IDataSink CreateDataSink(DataSinkOption option)
Parameters
Type Name Description
DataSinkOption option

The desired options for the DataSink.

Returns
Type Description
IDataSink

ReadAsync(UInt32, UInt32)

Reads and returns data read from offset with size. You have to make sure not to read past the end of your data.

Declaration
public IAsyncOperation<IBuffer> ReadAsync(uint size, uint offset)
Parameters
Type Name Description
System.UInt32 size

The requested amount of data to read.

System.UInt32 offset

The offset into the data source to start reading from.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IBuffer>

ReplaceWithDataSinkAsync(IDataSink)

This method should replace your current data with the one written into the data sink. To create a data sink, see CreateDataSink(DataSinkOption).
Depending on the DataSinkOption used you either have to append or replace the data.

Declaration
public IAsyncOperation<bool> ReplaceWithDataSinkAsync(IDataSink dataSink)
Parameters
Type Name Description
IDataSink dataSink

The object instantiated with CreateDataSink(DataSinkOption).

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

Implements

IDataProvider