Table of Contents

Class ServiceClient

Namespace
Virtufin.Api.Client
Assembly
Virtufin.Api.Client.dll

Dynamic client for invoking methods on a specific service through the gateway. Allows syntax like: client.Gateway.workmanager.SomeMethod().

RPC method names are accessed as dynamic members. Each member returns a Func<Dictionary, Task<Dictionary>> that invokes the method via the Gateway's InvokeJson RPC.

ServiceClient instances are created by TryGetMember(GetMemberBinder, out object?) (i.e. client.Gateway.workmanager) and cached per service name.

public class ServiceClient : DynamicObject, IDynamicMetaObjectProvider
Inheritance
ServiceClient
Implements
Inherited Members

Examples

using var client = new ApiClient();
dynamic workers = client.Gateway.workmanager;
var result = await workers.ListWorkers();

Constructors

ServiceClient(GatewayClient, string)

Creates a new ServiceClient for a specific service.

public ServiceClient(GatewayClient gateway, string serviceName)

Parameters

gateway GatewayClient

The parent GatewayClient instance.

serviceName string

The name of the service to target.

Methods

InvokeAsync(string, Dictionary<string, object?>?)

Invokes a method asynchronously on the service.

public Task<Dictionary<string, object?>> InvokeAsync(string method, Dictionary<string, object?>? requestData = null)

Parameters

method string

The method name to invoke.

requestData Dictionary<string, object>

Optional request data as dictionary.

Returns

Task<Dictionary<string, object>>

The response as a dictionary.

TryGetMember(GetMemberBinder, out object?)

Dynamic property access returns a dynamic method that invokes the named method.

public override bool TryGetMember(GetMemberBinder binder, out object? result)

Parameters

binder GetMemberBinder
result object

Returns

bool