DeviceRepositoryV3.GetAllByAgent Method

Get all by agent

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ISimpleCollection<SimpleDeviceV1> GetAllByAgent(
	Guid agentId
)

Parameters

agentId  Guid
The agent identifier.

Return Value

ISimpleCollection<SimpleDeviceV1>
Collection of devices

Implements

ISimpleClientDeviceRepositoryV3.GetAllByAgent(Guid)
Example
Following example displays how to retrieve all devices by agent ID
C#
using System;
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;

public class Example
{
    static void Main()
    {
        // Create instance of simple client
        var client = new SimpleClient(ConnectorConfiguration.HttpClient);

        ConnectionInfoV1 token;
        // Connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);
            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        // For this example we first create an example agent
        var exampleAgent = new SimpleAgentV1(Guid.NewGuid(),
            "ExampleAgent",
            EntityRoot.Agent,
            AgentCategory.RunnerManager);
        client.Agents.Create(exampleAgent);

        // Create the Example Device (Bus Controller)
        var exampleBusController = new SimpleDeviceV1(
            Guid.NewGuid(),
            "BUS",
            EntityRoot.Device,
            Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236")
        );
        // Now we assign agent to the example bus controller
        exampleBusController.Data["DefaultAgent"] = exampleAgent.Id;

        // Now we create the device in database
        client.Devices.Create(exampleBusController);

        // Retrieve all devices by Agent
        var exampleResult = client.Devices.GetAllByAgent(exampleAgent.Id);

        // Console Output should include name of the example bus controller device, 'BUS'
        foreach (var device in exampleResult)
        {
            Console.WriteLine(device.Name);
        }

        // Disconnect from server
        client.Disconnect();
    }
}
See Also

Reference

DeviceRepositoryV3 Class
Gamanet.C4.SDK Namespace