public void ObjectIsCached() { var cache = new CacheList <int, TestObject>(); var obj1 = cache.Get(0, (i) => new TestObject(1)); var obj2 = cache.Get(0, (i) => new TestObject(2)); Assert.AreEqual(obj1, obj2); Assert.AreEqual(1, obj2.Index); }
public void StoreNewValueFromCallback() { var cache = new CacheList <int, TestObject>(); var obj1 = cache.Get(0, (i) => new TestObject(i)); Assert.IsNotNull(obj1); }
public GameEntity GetPlayerEntity(int playerId) { return(_cachedPlayerEntity.Get(playerId, (id) => this.GetEntities(GameMatcher.Player) .Where(e => e.player.PlayerId == id) .FirstOrDefault() )); }
public void AddAbility() { _entity.AddAbility ( _cacheAbility.Get ( _data.AbilityClassFullName, (name) => (Ability)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(name) ) ); }
protected override void Execute(List <CardEntity> entities) { foreach (var e in entities) { var deck = _playerDeckCache.Get(e.owner.Entity, (playerEntity) => _gameContext.GetEntities(GameMatcher.PlayerDeck) .Where(p => p == playerEntity) .First() .playerDeck.PlayerDeckObject ); deck.AddCard(e.view.GameObject); } }