SiLA2.Client.Dynamic 7.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SiLA2.Client.Dynamic --version 7.5.1                
NuGet\Install-Package SiLA2.Client.Dynamic -Version 7.5.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiLA2.Client.Dynamic" Version="7.5.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SiLA2.Client.Dynamic --version 7.5.1                
#r "nuget: SiLA2.Client.Dynamic, 7.5.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SiLA2.Client.Dynamic as a Cake Addin
#addin nuget:?package=SiLA2.Client.Dynamic&version=7.5.1

// Install SiLA2.Client.Dynamic as a Cake Tool
#tool nuget:?package=SiLA2.Client.Dynamic&version=7.5.1                

Introduction

SilA2 Client implementation is hosted at https://gitlab.com/SiLA2/sila_csharp/-/tree/master/src/SiLA2.Client.Dynamic . You´ll find an example implementation at https://gitlab.com/SiLA2/sila_csharp/-/blob/master/src/Tests/SiLA2.IntegrationTests.DynamicClientApp/ .

Prerequisites

Getting Started

  • Create Console Application
  • Search for & reference SiLA2.Client.Dynamic package at Nuget.org in Visual Studio or https://www.nuget.org/
  • Add appsettings.json to the project...something like the following...
{
  "DetailedErrors": true,
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Grpc": "Information",
      "Microsoft": "Information"
    }
  },
  "Connection": {
    "FQHN": "127.0.0.1",
    "Port": 50052,
    "ServerDiscovery": {
      "NIC": "Ethernet",
      "ServiceName": "_sila._tcp"
    }
  }
}

You might adjust FQHN (IP or CIDR or Fully Qualified Host Name), Port and NIC (Network Interface e.g. Ethernet, eth0, WLAN0 etc.). ServiceName ist part of mDNS message suffix used for server search in local network.

  • Load configuration and setup IoC Container
 var configBuilder = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
 var configuration = configBuilder.Build();

 var client = new DynamicConfigurator(configuration, args);
  • Search for SiLA2 servers
 _ = await client.GetFeatures();

or add known servers

_ = await client.GetFeatures(new[] { new ConnectionInfo("127.0.0.1", 50052) });

Examples

An Example Server can be found at https://gitlab.com/SiLA2/sila_csharp/-/tree/master/src/Tests/SiLA2.IntegrationTests.ServerApp but you could use any other SiLA2 Server implementation for example found in sila_python or sila_java...

Call Unobservable Property
 private static void CallUnobservableProperty(IDynamicConfigurator client, GrpcChannel channel)
 {
     Console.WriteLine($"{Environment.NewLine}Calling unobservable property to get Server UUID...");
     var silaServiceFeature = client.ServerFeatureMap[_connectionInfo].Values.Single(x => x.FullyQualifiedIdentifier == "org.silastandard/core/SiLAService/v1");
     dynamic serverUUIDResponse = client.DynamicMessageService.GetUnobservableProperty("ServerUUID", channel, silaServiceFeature);
     Console.WriteLine($"Response => ServerUUID: {serverUUIDResponse.ServerUUID.Value}");
 }
Call Unobservable Command
private static void CallUnobservableCommand(IDynamicConfigurator client, GrpcChannel channel)
{
    const string COMMAND_IDENTIFIER = "JoinIntegerAndString";
    Console.WriteLine($"{Environment.NewLine}Calling Unobservable Command '{COMMAND_IDENTIFIER}' with Integer and String Parameter...");

    int intVal = int.MinValue;
    do
    {
        Console.WriteLine("Enter Integer");
        string tmp = Console.ReadLine();
        if (int.TryParse(tmp, out int intValTmp))
        {
            intVal = intValTmp;
            break;
        }
    } while (true);
    Console.WriteLine("Enter String");
    string strVal = Console.ReadLine();

    var unobservableCommandFeature = client.ServerFeatureMap[_connectionInfo].Values.Single(x => x.FullyQualifiedIdentifier == "org.silastandard/test/UnobservableCommandTest/v1");

    Dictionary<string, object> payloadMap = new Dictionary<string, object> {
            { "Integer", new Sila2.Org.Silastandard.Protobuf.Integer { Value = intVal } },
            { "String", new Sila2.Org.Silastandard.Protobuf.String { Value = strVal } }
        };

    dynamic joinIntAndStringResponse = client.DynamicMessageService.ExecuteUnobservableCommand(COMMAND_IDENTIFIER, channel, unobservableCommandFeature, payloadMap);
    Console.WriteLine($"Response => JoinedParameters: {joinIntAndStringResponse.JoinedParameters.Value}");
}
Call Observable Property
private async static Task CallObservableProperty(IDynamicConfigurator client, GrpcChannel channel)
{
    const string PROPERTY_NAME = "Alternating";
    Console.WriteLine($"{Environment.NewLine}Calling Observable Property returning alternating Boolean Value for 7 seconds...");
    var silaObservablePropertyFeature = client.ServerFeatureMap[_connectionInfo].Values.Single(x => x.FullyQualifiedIdentifier == "org.silastandard/test/ObservablePropertyTest/v1");
    var response = client.DynamicMessageService.SubcribeObservableProperty(PROPERTY_NAME, channel, silaObservablePropertyFeature);

    var asyncEnumerator = response.GetAsyncEnumerator();

    int i = 0;
    while (await asyncEnumerator.MoveNextAsync() && i <= 7)
    {
        dynamic responseResultPropertyValue = asyncEnumerator.Current;
        Console.WriteLine($"Response => {responseResultPropertyValue.Alternating.Value}");
        i++;
    }
}
Call Observable Command
private static async Task CallObservableCommand(DynamicConfigurator client, GrpcChannel channel)
{
    const string OPERATION_NAME = "Count";
    const double DELAY = 1.0;
    Console.WriteLine($"{Environment.NewLine}Calling Observable Command for 7 seconds with delay of 1 second...");

    var observableCommandFeature = client.ServerFeatureMap[_connectionInfo].Values.Single(x => x.FullyQualifiedIdentifier == "org.silastandard/test/ObservableCommandTest/v1");

    IDictionary<string, object> payloadMap = new Dictionary<string, object> {
        { "N", new Sila2.Org.Silastandard.Protobuf.Integer { Value = 7 } },
        { "Delay", new Sila2.Org.Silastandard.Protobuf.Real { Value = DELAY } }
    };

    var response = client.DynamicMessageService.ExecuteObservableCommand(OPERATION_NAME, channel, observableCommandFeature, payloadMap);

    var asyncEnumerator = response.Item2.GetAsyncEnumerator();

    while (await asyncEnumerator.MoveNextAsync())
    {
        Console.WriteLine($"Response => {asyncEnumerator.Current.CommandStatus}");
        if (asyncEnumerator.Current.CommandStatus == ExecutionInfo.Types.CommandStatus.FinishedSuccessfully
            || asyncEnumerator.Current.CommandStatus == ExecutionInfo.Types.CommandStatus.FinishedWithError)
        {
            break;
        }
    }

    dynamic result = client.DynamicMessageService.GetObservableCommandResult(response.Item1.CommandExecutionUUID, OPERATION_NAME, channel, observableCommandFeature, response.Item3);
    Console.WriteLine($"Result Response => Number of Iterations => {result.IterationResponse.Value}");
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.1.2 88 10/20/2024
8.1.1 108 8/31/2024
8.1.0 297 2/11/2024
8.0.0 200 11/15/2023
7.5.4 136 10/27/2023
7.5.3 167 7/19/2023
7.5.2 156 7/3/2023
7.5.1 152 6/2/2023