Class StorageFileDataProvider

Implements a disposable IDataProvider for a Windows.Storage.StorageFile.

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

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; }
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

CreateStorageFileDataProviderAsync(IStorageFile)

Creates a StorageFileDataProvider from an Windows.Storage.IStorageFile.

Declaration
public static IAsyncOperation<StorageFileDataProvider> CreateStorageFileDataProviderAsync(IStorageFile file)
Parameters
Type Name Description
Windows.Storage.IStorageFile file
Returns
Type Description
Windows.Foundation.IAsyncOperation<StorageFileDataProvider>

Dispose()

Declaration
public void Dispose()

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
System.IDisposable