Table of Contents

Class JsonRpcTargetOptions

Namespace
StreamJsonRpc
Assembly
StreamJsonRpc.dll

Options that may customize how a target object is added to a JsonRpc instance.

public class JsonRpcTargetOptions
Inheritance
JsonRpcTargetOptions
Inherited Members

Constructors

JsonRpcTargetOptions()

Initializes a new instance of the JsonRpcTargetOptions class.

public JsonRpcTargetOptions()

JsonRpcTargetOptions(JsonRpcTargetOptions)

Initializes a new instance of the JsonRpcTargetOptions class.

public JsonRpcTargetOptions(JsonRpcTargetOptions copyFrom)

Parameters

copyFrom JsonRpcTargetOptions

An instance to copy all property values from.

Properties

AllowFlexibleNamedArgumentMatching

Gets or sets a value indicating whether named arguments may omit target method parameters or include names that do not match any parameter.

public bool AllowFlexibleNamedArgumentMatching { get; set; }

Property Value

bool

The default value is false.

Remarks

When true, named arguments that do not match any target method parameter are ignored. Parameters without a corresponding named argument receive their declared default value, or the default value for their parameter type when no default is declared. Parameters annotated with RequiredAttribute must have a corresponding named argument.

This option does not affect positional arguments.

A target cannot be registered with this option enabled when distinct methods resolve to the same RPC method name, because flexible argument matching cannot reliably disambiguate overloads. A pair that differs only by a trailing CancellationToken is allowed because it has one wire signature.

Each target method must also have unique RPC parameter names after applying ParameterNameTransform and any JsonRpcParameterAttribute annotations.

AllowNonPublicInvocation

Gets or sets a value indicating whether non-public methods/events on target objects can be invoked by remote clients.

public bool AllowNonPublicInvocation { get; set; }

Property Value

bool

The default value is false.

Remarks

The default for this property was true in the 1.x versions.

ClientRequiresNamedArguments

Gets or sets a value indicating whether JSON-RPC named arguments should be used in callbacks sent back to the client.

public bool ClientRequiresNamedArguments { get; set; }

Property Value

bool

The default value is false.

Remarks

An example of impact of this setting is when the client sends an IProgress<T> argument and this server will call Report(T) on that argument. The notification that the server then sends back to the client may use positional or named arguments in that notification. Named arguments are used if and only if this property is set to true.

DisposeOnDisconnect

Gets or sets a value indicating whether to dispose of the target object when the connection with the remote party is lost.

public bool DisposeOnDisconnect { get; set; }

Property Value

bool

Remarks

The target object may implement IAsyncDisposable, IAsyncDisposable or IDisposable. The first implemented interface from this list is the one whose dispose method will be invoked.

Exceptions thrown from the dispose method will be aggregated into Completion.

EventNameTransform

Gets or sets a function that takes the CLR event name and returns the RPC event name used in notification messages. This method is useful for adding prefixes to all events, or making them camelCased.

public Func<string, string>? EventNameTransform { get; set; }

Property Value

Func<string, string>

MethodNameTransform

Gets or sets a function that takes the CLR method name and returns the RPC method name. This method is useful for adding prefixes to all methods, or making them camelCased.

public Func<string, string>? MethodNameTransform { get; set; }

Property Value

Func<string, string>

NotifyClientOfEvents

Gets or sets a value indicating whether events raised on the target object should be relayed to the client via a JSON-RPC notify message.

public bool NotifyClientOfEvents { get; set; }

Property Value

bool

The default is true.

ParameterNameTransform

Gets or sets a function that takes the effective pre-transform parameter name and returns the RPC parameter name. The effective pre-transform name is the CLR parameter name unless JsonRpcParameterAttribute overrides it. This function applies to named arguments only.

public Func<string, string>? ParameterNameTransform { get; set; }

Property Value

Func<string, string>

UseSingleObjectParameterDeserialization

Gets or sets a value indicating whether JSON-RPC named arguments should all be deserialized into the RPC method's first parameter.

public bool UseSingleObjectParameterDeserialization { get; set; }

Property Value

bool

Remarks

This value serves as a default for UseSingleObjectParameterDeserialization for members that have no JsonRpcMethodAttribute applied.