Table of Contents

Class ServiceRpcDescriptor

Namespace
Microsoft.ServiceHub.Framework
Assembly
Microsoft.ServiceHub.Framework.dll

A description of a service to help automate connecting to it.

public abstract class ServiceRpcDescriptor
Inheritance
ServiceRpcDescriptor
Derived
Inherited Members

Constructors

ServiceRpcDescriptor(ServiceMoniker, Type?)

Initializes a new instance of the ServiceRpcDescriptor class.

public ServiceRpcDescriptor(ServiceMoniker serviceMoniker, Type? clientInterface)

Parameters

serviceMoniker ServiceMoniker

The service moniker.

clientInterface Type

The interface type that the client's "callback" RPC target is expected to implement. May be null if the service does not invoke methods on the client.

ServiceRpcDescriptor(ServiceRpcDescriptor)

Initializes a new instance of the ServiceRpcDescriptor class and initializes all fields based on a template instance.

protected ServiceRpcDescriptor(ServiceRpcDescriptor copyFrom)

Parameters

copyFrom ServiceRpcDescriptor

The instance to copy all fields from.

Properties

ClientInterface

Gets the interface type that the client's "callback" RPC target is expected to implement.

public Type? ClientInterface { get; }

Property Value

Type

May be null if the service does not invoke methods on the client.

JoinableTaskFactory

Gets the JoinableTaskFactory that may be applied to the constructed RPC connection.

public JoinableTaskFactory? JoinableTaskFactory { get; }

Property Value

JoinableTaskFactory

Moniker

Gets the moniker for the service.

public ServiceMoniker Moniker { get; }

Property Value

ServiceMoniker

MultiplexingStream

Gets the Nerdbank.Streams.MultiplexingStream that may be used by constructed clients or servers.

public MultiplexingStream? MultiplexingStream { get; }

Property Value

MultiplexingStream

null by default.

Protocol

Gets a non-localized name of the protocol supported by this instance.

public abstract string Protocol { get; }

Property Value

string

TraceSource

Gets the TraceSource to be used on constructed clients or servers.

public TraceSource? TraceSource { get; }

Property Value

TraceSource

null by default.

Methods

Clone()

Creates a copy of this instance with all the same properties.

protected abstract ServiceRpcDescriptor Clone()

Returns

ServiceRpcDescriptor

The copy.

Remarks

Derived types should override this method to create a new instance of their own type, using the ServiceRpcDescriptor(ServiceRpcDescriptor) copy constructor, then copy all their unique properties from this instance to the new one before returning the new one.

ConstructLocalProxy<T>(T?)

Gives the ServiceRpcDescriptor a chance to wrap a local target object so that interacting with it behaves similarly to if it were a remote target that was using RPC.

public virtual T? ConstructLocalProxy<T>(T? target) where T : class

Parameters

target T

The local target object. May be null, which will result in null being returned.

Returns

T

The proxy wrapper (or null if target is null); or possibly the original target object if this method is not overriden by a derived-type.

Type Parameters

T

The interface that defines the RPC contract for communicating with the target.

ConstructRpc(object, IDuplexPipe)

Establishes an RPC connection to a given object over an IDuplexPipe, allowing the remote party to invoke methods locally on the given object.

public void ConstructRpc(object rpcTarget, IDuplexPipe pipe)

Parameters

rpcTarget object

The target of any RPC calls received over the supplied pipe. Raising events defined on this object may result in notifications being forwarded to the remote party. If this object implements IDisposable, Dispose() will be invoked when the client closes their connection.

pipe IDuplexPipe

The pipe the rpcTarget should use to communicate.

ConstructRpcConnection(IDuplexPipe)

Establishes an RPC connection over an IDuplexPipe.

public abstract ServiceRpcDescriptor.RpcConnection ConstructRpcConnection(IDuplexPipe pipe)

Parameters

pipe IDuplexPipe

The pipe used to send and receive RPC messages.

Returns

ServiceRpcDescriptor.RpcConnection

An object representing the lifetime of the connection.

Remarks

Callers are expected to call ConstructRpcClient<T>() and/or AddLocalRpcTarget(object) on the result value before invoking StartListening() to begin the RPC session.

ConstructRpc<T>(IDuplexPipe)

Creates an RPC client proxy over a given IDuplexPipe without providing a local RPC target for the remote party to invoke methods locally.

public T ConstructRpc<T>(IDuplexPipe pipe) where T : class

Parameters

pipe IDuplexPipe

The pipe used to communicate with the remote party.

Returns

T

The generated proxy. This value should be disposed of when no longer needed, if it implements IDisposable at runtime. A convenient disposal syntax is:

(proxy as IDisposable)?.Dispose();

Type Parameters

T

The type of the RPC proxy to generate for invoking methods on the remote party or receiving events from it.

ConstructRpc<T>(object?, IDuplexPipe)

Creates an RPC client proxy over a given IDuplexPipe and provides a local RPC target for the remote party to invoke methods locally.

public T ConstructRpc<T>(object? rpcTarget, IDuplexPipe pipe) where T : class

Parameters

rpcTarget object

A local RPC target on which the remote party can invoke methods. This is usually optional for requestors of a service but is typically expected for the proffering services to provide. If this object implements IDisposable, Dispose() will be invoked when the client closes their connection.

pipe IDuplexPipe

The pipe used to communicate with the remote party.

Returns

T

The generated proxy. This value should be disposed of when no longer needed, if it implements IDisposable at runtime. A convenient disposal syntax is:

(proxy as IDisposable)?.Dispose();

Type Parameters

T

The type of the RPC proxy to generate for invoking methods on the remote party or receiving events from it.

WithJoinableTaskFactory(JoinableTaskFactory?)

Returns an instance of ServiceRpcDescriptor that resembles this one, but with the JoinableTaskFactory property set to the specified value.

public ServiceRpcDescriptor WithJoinableTaskFactory(JoinableTaskFactory? joinableTaskFactory)

Parameters

joinableTaskFactory JoinableTaskFactory

The value for the modified property..

Returns

ServiceRpcDescriptor

A clone of this instance, with the property changed. Or this same instance if the property already matches.

WithMultiplexingStream(MultiplexingStream?)

Returns an instance of ServiceRpcDescriptor that resembles this one, but with the MultiplexingStream property set to the specified value and Nerdbank.Streams.MultiplexingStream.Options set to null.

[Obsolete("Use the WithMultiplexingStream(MultiplexingStream.Options) overload as may be defined in a derived type instead.")]
public virtual ServiceRpcDescriptor WithMultiplexingStream(MultiplexingStream? multiplexingStream)

Parameters

multiplexingStream MultiplexingStream

The Nerdbank.Streams.MultiplexingStream that may be used by constructed clients or servers.

Returns

ServiceRpcDescriptor

A clone of this instance, with the property changed. Or this same instance if the property already matches.

WithServiceMoniker(ServiceMoniker)

Returns an instance of ServiceRpcDescriptor that resembles this one, but with the ServiceMoniker property set to the specified value.

public ServiceRpcDescriptor WithServiceMoniker(ServiceMoniker moniker)

Parameters

moniker ServiceMoniker

The moniker to be used in place of the original.

Returns

ServiceRpcDescriptor

A clone of this instance, with the property changed. Or this same instance if the property already matches.

WithTraceSource(TraceSource?)

Returns an instance of ServiceRpcDescriptor that resembles this one, but with the TraceSource property set to the specified value.

public ServiceRpcDescriptor WithTraceSource(TraceSource? traceSource)

Parameters

traceSource TraceSource

The receiver of trace messages.

Returns

ServiceRpcDescriptor

A clone of this instance, with the property changed. Or this same instance if the property already matches.