public ShellViewModel() { Players = new ObservableCollection <IPlayerViewModel>(); // Get the list of player models // from the database (ICollection<IPlayer>) var players = GetCollectionOfPlayerModels(); foreach (var player in players) { var vm = PlayerViewModelFactory.Create(player); Players.Add(vm); } }
public GameViewModel( CompletedGamespaceViewModel completedGamespace, IStore <GameStateModel> gameStateStore, IdleGamespaceViewModel idleGamespace, PausedGamespaceViewModel pausedGamespace, PlayerViewModelFactory playerViewModelFactory, ReadyGamespaceViewModel readyGamespace, RunningGamespaceViewModel runningGamespace, SetupGamespaceViewModel setupGamespace) { Gamespace = gameStateStore .Select(gameState => gameState.Phase) .DistinctUntilChanged() .Select(phase => (object)(phase switch { GamePhase.Complete => completedGamespace, GamePhase.Idle => idleGamespace, GamePhase.Paused => pausedGamespace, GamePhase.Ready => readyGamespace, GamePhase.Running => runningGamespace, GamePhase.Setup => setupGamespace, _ => throw new InvalidOperationException("Dafuq did you do to the game state?"), }))