Table of Contents

Interface IServiceBroker

Namespace
Nerdbank.JsonRpc.BrokeredServices
Assembly
Nerdbank.JsonRpc.dll

Activates services by contract, without exposing where they are implemented.

public interface IServiceBroker
Extension Methods

Methods

GetCapabilitiesAsync(ServiceMoniker, CancellationToken)

Gets the capabilities of the selected registration without activating it.

ValueTask<IReadOnlyList<string>?> GetCapabilitiesAsync(ServiceMoniker moniker, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested service.

cancellationToken CancellationToken

Cancels lookup.

Returns

ValueTask<IReadOnlyList<string>>

Stable capability identifiers, or null when no registration exists.

GetConnectionAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)

Acquires a channel and capabilities from the same winning registration.

ValueTask<BrokeredServiceConnection?> GetConnectionAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested identity.

options ServiceActivationOptions

Options for the activation.

cancellationToken CancellationToken

Cancels acquisition.

Returns

ValueTask<BrokeredServiceConnection>

The caller-owned connection, or null if unavailable.

GetPipeAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)

Acquires a service's raw RPC pipe.

ValueTask<IDuplexPipe?> GetPipeAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested service.

options ServiceActivationOptions

Options for this activation.

cancellationToken CancellationToken

Cancels this request.

Returns

ValueTask<IDuplexPipe>

A caller-owned pipe, or null if the service is unavailable. Complete both ends when finished.

GetProxyAsync<T>(IJsonRpcDescriptor<T>, ServiceActivationOptions, CancellationToken)

Acquires a service proxy whose type is inferred from its descriptor.

ValueTask<T?> GetProxyAsync<T>(IJsonRpcDescriptor<T> descriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default) where T : class

Parameters

descriptor IJsonRpcDescriptor<T>

The descriptor, including generated proxy support.

options ServiceActivationOptions

Options for this activation.

cancellationToken CancellationToken

Cancels this request.

Returns

ValueTask<T>

A caller-owned proxy, or null if the service is unavailable.

Type Parameters

T

The service interface.

Events

AvailabilityChanged

Occurs when previously queried service availability may have changed.

event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged

Event Type

EventHandler<BrokeredServicesChangedEventArgs>