public IPeripheralsGroup GetOrCreate(string name, IEnumerable <IPeripheral> peripherals) { IPeripheralsGroup existingResult = null; var result = (PeripheralsGroup)existingResult; if (!TryGetByName(name, out existingResult)) { result = new PeripheralsGroup(name, machine); groups.Add(result); } foreach (var p in peripherals) { result.Add(p); } return(result); }
public bool TryGetByName(string name, out IPeripheralsGroup group) { group = ActiveGroups.SingleOrDefault(x => x.Name == name); return(group != null); }
public bool TryGetAnyGroupContaining(IPeripheral peripheral, out IPeripheralsGroup group) { group = groups.SingleOrDefault(x => x.Contains(peripheral)); return(group != null); }