PresentationInvocation class

Namespace Runic.Desktop · Runic.Desktop 0.7.0-preview.5

public sealed class PresentationInvocation

Represents one active presentation invocation.

Remarks

The invocation is active only while its handler runs. After the handler returns or its task completes, reading arguments and the session operations on this object throw ObjectDisposedException; keep PresentationInvocation.Session to address the session later.

Properties

ArgumentCount

public int ArgumentCount { get; }

Gets the number of arguments supplied by the page.

Exceptions

ObjectDisposedException

The invocation is no longer active.

Capability

public string Capability { get; }

Gets the capability or element name the event was dispatched to; empty for connection and navigation events.

CorrelationId

public string CorrelationId { get; }

Gets the opaque identity shared with any redacted diagnostic for this invocation.

InvocationId

public ulong InvocationId { get; }

Gets the event number, taken from one counter per surface that all of its sessions share.

Kind

public PresentationEventKind Kind { get; }

Gets the kind of event being delivered.

Session

public PresentationSession Session { get; }

Gets the presentation session that raised the invocation.

SessionId

public ulong SessionId { get; }

Gets the opaque identifier of the raising session; the same value as PresentationSession.Id.

Surface

public DesktopSurface Surface { get; }

Gets the surface that received the invocation.

Methods

CloseSessionAsync

public Task CloseSessionAsync(CancellationToken cancellationToken = default)

Closes the raising session.

Parameters

cancellationToken

Cancels the close request.

Returns

A task that completes when the session close has been requested.

Exceptions

ObjectDisposedException

The invocation is no longer active.

InvalidOperationException

The session is no longer connected.

GetBoolean

public bool GetBoolean(int index = 0)

Gets an argument as a Boolean, accepting 1, 0, true and false (case-insensitive).

Parameters

index

The zero-based argument index.

Returns

The parsed argument.

Exceptions

ArgumentOutOfRangeException

index is not less than PresentationInvocation.ArgumentCount.

OverflowException

index is negative.

FormatException

The argument is not a Boolean value.

ObjectDisposedException

The invocation is no longer active.

GetBytes

public ReadOnlyMemory<byte> GetBytes(int index = 0)

Gets the raw bytes of an argument.

Parameters

index

The zero-based argument index.

Returns

The argument bytes as sent by the page.

Exceptions

ArgumentOutOfRangeException

index is not less than PresentationInvocation.ArgumentCount.

OverflowException

index is negative.

ObjectDisposedException

The invocation is no longer active.

GetDouble

public double GetDouble(int index = 0)

Gets an argument parsed as a double-precision number using the invariant culture.

Parameters

index

The zero-based argument index.

Returns

The parsed argument.

Exceptions

ArgumentOutOfRangeException

index is not less than PresentationInvocation.ArgumentCount.

OverflowException

index is negative.

FormatException

The argument is not a number.

ObjectDisposedException

The invocation is no longer active.

GetInt64

public long GetInt64(int index = 0)

Gets an argument parsed as a signed 64-bit integer using the invariant culture.

Parameters

index

The zero-based argument index.

Returns

The parsed argument.

Exceptions

ArgumentOutOfRangeException

index is not less than PresentationInvocation.ArgumentCount.

FormatException

The argument is not an integer.

OverflowException

index is negative, or the argument is outside the Int64 range.

ObjectDisposedException

The invocation is no longer active.

GetString

public string GetString(int index = 0)

Gets an argument decoded as UTF-8 text.

Parameters

index

The zero-based argument index.

Returns

The decoded argument.

Exceptions

ArgumentOutOfRangeException

index is not less than PresentationInvocation.ArgumentCount.

OverflowException

index is negative.

ObjectDisposedException

The invocation is no longer active.

public Task NavigateAsync(string url, CancellationToken cancellationToken = default)

Navigates the raising session only.

Parameters

url

The URL to navigate to.

cancellationToken

Cancels sending the navigation.

Returns

A task that completes when the navigation has been sent.

Exceptions

ObjectDisposedException

The invocation is no longer active.

InvalidOperationException

The session is no longer connected.

RunJavaScriptAsync

public Task RunJavaScriptAsync(string script, CancellationToken cancellationToken = default)

Runs JavaScript in the raising session only.

Parameters

script

The script to run.

cancellationToken

Cancels sending the script.

Returns

A task that completes when the script has been sent.

Exceptions

ObjectDisposedException

The invocation is no longer active.

InvalidOperationException

The session is no longer connected.

SendAsync

public Task SendAsync(string function, ReadOnlyMemory<byte> data, CancellationToken cancellationToken = default)

Sends opaque bytes to a page function in the raising session only.

Parameters

function

The name of the page function that receives the bytes.

data

The opaque payload.

cancellationToken

Cancels sending the payload.

Returns

A task that completes when the payload has been sent.

Exceptions

ArgumentException

function is null, empty or whitespace.

ObjectDisposedException

The invocation is no longer active.

InvalidOperationException

The session is no longer connected.

Remarks

An empty payload sends nothing.