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
ObjectDisposedExceptionThe 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.
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.
Methods
CloseSessionAsync
public Task CloseSessionAsync(CancellationToken cancellationToken = default) Closes the raising session.
Parameters
cancellationTokenCancels the close request.
Returns
A task that completes when the session close has been requested.
Exceptions
ObjectDisposedExceptionThe invocation is no longer active.
InvalidOperationExceptionThe 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
indexThe zero-based argument index.
Returns
The parsed argument.
Exceptions
ArgumentOutOfRangeExceptionindexis not less thanPresentationInvocation.ArgumentCount.OverflowExceptionindexis negative.FormatExceptionThe argument is not a Boolean value.
ObjectDisposedExceptionThe invocation is no longer active.
GetBytes
public ReadOnlyMemory<byte> GetBytes(int index = 0) Gets the raw bytes of an argument.
Parameters
indexThe zero-based argument index.
Returns
The argument bytes as sent by the page.
Exceptions
ArgumentOutOfRangeExceptionindexis not less thanPresentationInvocation.ArgumentCount.OverflowExceptionindexis negative.ObjectDisposedExceptionThe 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
indexThe zero-based argument index.
Returns
The parsed argument.
Exceptions
ArgumentOutOfRangeExceptionindexis not less thanPresentationInvocation.ArgumentCount.OverflowExceptionindexis negative.FormatExceptionThe argument is not a number.
ObjectDisposedExceptionThe 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
indexThe zero-based argument index.
Returns
The parsed argument.
Exceptions
ArgumentOutOfRangeExceptionindexis not less thanPresentationInvocation.ArgumentCount.FormatExceptionThe argument is not an integer.
OverflowExceptionindexis negative, or the argument is outside theInt64range.ObjectDisposedExceptionThe invocation is no longer active.
GetString
public string GetString(int index = 0) Gets an argument decoded as UTF-8 text.
Parameters
indexThe zero-based argument index.
Returns
The decoded argument.
Exceptions
ArgumentOutOfRangeExceptionindexis not less thanPresentationInvocation.ArgumentCount.OverflowExceptionindexis negative.ObjectDisposedExceptionThe invocation is no longer active.
NavigateAsync
public Task NavigateAsync(string url, CancellationToken cancellationToken = default) Navigates the raising session only.
Parameters
urlThe URL to navigate to.
cancellationTokenCancels sending the navigation.
Returns
A task that completes when the navigation has been sent.
Exceptions
ObjectDisposedExceptionThe invocation is no longer active.
InvalidOperationExceptionThe session is no longer connected.
RunJavaScriptAsync
public Task RunJavaScriptAsync(string script, CancellationToken cancellationToken = default) Runs JavaScript in the raising session only.
Parameters
scriptThe script to run.
cancellationTokenCancels sending the script.
Returns
A task that completes when the script has been sent.
Exceptions
ObjectDisposedExceptionThe invocation is no longer active.
InvalidOperationExceptionThe 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
functionThe name of the page function that receives the bytes.
dataThe opaque payload.
cancellationTokenCancels sending the payload.
Returns
A task that completes when the payload has been sent.
Exceptions
ArgumentExceptionfunctionisnull, empty or whitespace.ObjectDisposedExceptionThe invocation is no longer active.
InvalidOperationExceptionThe session is no longer connected.
Remarks
An empty payload sends nothing.