Class JsonRpcProxy
- Namespace
- Nerdbank.JsonRpc
- Assembly
- Nerdbank.JsonRpc.dll
Provides lifecycle and capability behavior shared by generated RPC and direct proxies.
public abstract class JsonRpcProxy : IClientProxy, IDisposable, IAsyncDisposable
- Inheritance
-
JsonRpcProxy
- Implements
- Inherited Members
- Extension Methods
Constructors
JsonRpcProxy(ServiceProxyContext, Type, IReadOnlyList<Type>)
Initializes a new instance of the JsonRpcProxy class for direct calls.
protected JsonRpcProxy(ServiceProxyContext context, Type primaryInterface, IReadOnlyList<Type> enabledInterfaces)
Parameters
contextServiceProxyContextThe target and policy context.
primaryInterfaceTypeThe always-enabled primary contract.
enabledInterfacesIReadOnlyList<Type>The additional enabled contracts.
JsonRpcProxy(IJsonRpcClient, JsonRpcProxyOptions, Type)
Initializes a new instance of the JsonRpcProxy class for RPC calls.
protected JsonRpcProxy(IJsonRpcClient client, JsonRpcProxyOptions options, Type primaryInterface)
Parameters
clientIJsonRpcClientThe RPC invocation client.
optionsJsonRpcProxyOptionsThe proxy options.
primaryInterfaceTypeThe always-enabled primary contract.
Properties
Client
Gets the RPC invocation client when this proxy uses RPC.
protected IJsonRpcClient Client { get; }
Property Value
Context
Gets the target context used by generated forwarding methods.
protected ServiceProxyContext Context { get; }
Property Value
LocalContext
Gets the direct-call context, or null when this proxy uses RPC.
protected ServiceProxyContext? LocalContext { get; }
Property Value
MethodNameTransform
Gets the transform used to compute RPC method names.
protected Func<string, string> MethodNameTransform { get; }
Property Value
UseNamedArguments
Gets a value indicating whether RPC arguments are named.
protected bool UseNamedArguments { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
DisposeUnowned()
Invokes the contract's remote disposal operation when no local resource is owned.
protected virtual void DisposeUnowned()
Is(Type)
Gets a value indicating whether a contract interface is enabled on this proxy.
public bool Is(Type type)
Parameters
typeTypeThe contract interface type to query.
Returns
Remarks
The primary contract and its inherited interfaces are always enabled on generated proxies. Enabling an additional interface also enables its inherited interfaces. Non-interface types return false.
Exceptions
- ArgumentNullException
Thrown when
typeis null.
IsInterfaceEnabled(Type, ServiceProxyLease)
Tests invocation capabilities against the retained target rather than the context's current generation.
protected bool IsInterfaceEnabled(Type type, ServiceProxyLease lease)
Parameters
typeTypeThe invoked contract.
leaseServiceProxyLeaseThe lease retaining the invocation target.
Returns
- bool
Whether both this proxy and the retained target enable the contract.
TryDispose()
Disposes the owned resource or direct-call context, if present.
protected bool TryDispose()
Returns
- bool
Whether disposal was handled without a remote call.