public IData GetDataForDevice(IOwnedDevice device) { IControlToken token; if (MemberTokens.TryGetValue(device, out token)) { return(token.GetDataForDevice(device)); } if (AutoAddDevices) { token = device.TakeControl(priority: Priority, name: Name); Add(device, token); return(token.GetDataForDevice(device)); } var sod = device as SingleOwnerDevice; if (sod != null) { return(sod.GetOwnerlessData()); } throw new ArgumentException("Unhandled device"); }
/// <summary> /// Lock if group token is configured for auto add /// </summary> /// <param name="device"></param> /// <returns>True if device is controlled by this group token</returns> public bool LockAndGetDataFromDevice(IOwnedDevice device) { if (MemberTokens.ContainsKey(device)) { return(true); } if (!AutoAddDevices) { return(false); } // Add MemberTokens.Add(device, device.TakeControl(Priority, Name)); return(true); }
public IData GetDataForDevice(IOwnedDevice device) { IControlToken token; if (MemberTokens.TryGetValue(device, out token)) { return token.GetDataForDevice(device); } if (AutoAddDevices) { token = device.TakeControl(priority: Priority, name: Name); Add(device, token); return token.GetDataForDevice(device); } var sod = device as SingleOwnerDevice; if (sod != null) return sod.GetOwnerlessData(); throw new ArgumentException("Unhandled device"); }
/// <summary> /// Lock if group token is configured for auto add /// </summary> /// <param name="device"></param> /// <returns>True if device is controlled by this group token</returns> public bool LockAndGetDataFromDevice(IOwnedDevice device) { if (MemberTokens.ContainsKey(device)) return true; if (!AutoAddDevices) return false; // Add MemberTokens.Add(device, device.TakeControl(Priority, Name)); return true; }