private IComputerDevice Create(ComputerDeviceId device) { return(device switch { ComputerDeviceId.Screen => new ScreenDevice(), ComputerDeviceId.Power => new PowerDevice(), _ => throw new ArgumentOutOfRangeException(nameof(device), $"Device '{device}' is not supported.") });
private IComputerDevice Get(ComputerDeviceId device) => ImmutableInterlocked.GetOrAdd(ref _devices, device, Create);