Skip to content

list_get_module

Vladimir edited this page Feb 14, 2020 · 1 revision

Getting module from list

RelaysEnumerator en = new RelaysEnumerator();
IEnumerable<RelayInfo> relaysInfo = en.CollectDevices();

string id = "BRDID";
RelayInfo relayInfo = relaysInfo.FirstOrDefault(x => x.Id == id);

if (relayInfo != null) {
    Relay relay = new Relay(relayInfo);

    if (relay != null) {
        ...
    }
}

or

RelaysEnumerator en = new RelaysEnumerator();
IEnumerable<RelayInfo> relaysInfo = en.CollectDevices();

string id = "BRDID";
Relay relayInfo = relaysInfo
    .Where(x => x.Id = id)
    .Select(x => new Relay(x))
    .FirstOrDefault();

if (relay != null) {
    ...
}