Beispiel #1
0
 public ValidatingModel()
 {
     _properties         = new KeyedCollectionBase <string, PropertyInfo>(p => p.Name);
     _propertyValidators = new Dictionary <string, Validator>();
     _validationResults  = new Dictionary <string, ValidationResults>();
     PopulateValidators();
 }
Beispiel #2
0
 public AppContext()
 {
     _accessLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
     _dispatcher = Dispatcher.CurrentDispatcher;
     _allPlayers = new KeyedCollectionBase <int, IPlayer>(o => o.PlayerID);
     _defaultMusicLibrary.Load(DefaultMusicLibraryPath);
     _audioTrace = false;    // just tracing audio into Log.txt
     HookEventHandlers();
 }
        public static void Mutate <TKey, TItem>(
            this KeyedCollectionBase <TKey, TItem> collection,
            TKey key,
            Func <TItem, TItem> mutation
            ) where TKey : notnull
        {
            Check.NotNull(collection, nameof(collection));
            Check.NotNull(key, nameof(key));
            Check.NotNull(mutation, nameof(mutation));

            collection[key] = mutation(collection[key]);
        }
Beispiel #4
0
        public DesignTimeAppContext()
        {
            if (PlayerContext.Current == null ||
                PlayerContext.Current.Players.Count == 0)
            {
                PlayerContext.Current = new PlayerContext(
                    new ArrayWrapper <Player>(
                        new[]
                {
                    new Player
                    {
                        EmpireID = GameContext.Current.Civilizations.FirstOrDefault(o => o.IsEmpire).CivID,
                        Name     = "Local Player",
                        PlayerID = Player.GameHostID
                    }
                }));
            }

            _lobbyData = new LobbyData
            {
                Empires     = GameContext.Current.Civilizations.Where(o => o.IsEmpire).Select(o => o.Key).ToArray(),
                GameOptions = GameContext.Current.Options,
                Players     = PlayerContext.Current.Players.ToArray(),
                Slots       = new[]
                {
                    new PlayerSlot
                    {
                        Claim      = SlotClaim.Assigned,
                        EmpireID   = PlayerContext.Current.Players[0].EmpireID,
                        EmpireName = PlayerContext.Current.Players[0].Empire.Key,
                        IsClosed   = false,
                        Player     = PlayerContext.Current.Players[0],
                        SlotID     = 0,
                        Status     = SlotStatus.Taken
                    }
                }
            };

            _players = new KeyedCollectionBase <int, IPlayer>(o => o.PlayerID)
            {
                PlayerContext.Current.Players[0]
            };
        }
 protected KeyedMutatorBase(KeyedCollectionBase <TKey, TItem> collection)
 => _collection = collection;