Class ServiceClient
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
gatewayGatewayClientThe parent GatewayClient instance.
serviceNamestringThe 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
methodstringThe method name to invoke.
requestDataDictionary<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
binderGetMemberBinderresultobject