public IQueryable <T> All() { if (_cache == null || (DateTime.Now - _lastRefresh) > _refreshInterval) { _cache = _readOnlyRepositoryToCache.All(); _lastRefresh = DateTime.Now; } return(_cache); }
private async Task ValidateCharacterClassAbilities(MagusTtkCharacterClassDefinitionDto characterClassDefinition, Dictionary <string, int> classAbilities, IReadOnlyRepository <AbilityDefinition> abilityRepo, CancellationToken cancellationToken = default) { if (characterClassDefinition == null) { throw new ArgumentNullException(nameof(characterClassDefinition)); } if (classAbilities == null) { throw new ArgumentNullException(nameof(classAbilities)); } if (abilityRepo == null) { throw new ArgumentNullException(nameof(abilityRepo)); } int expectedAbilityCount = await abilityRepo.Count(null, cancellationToken); // ha nem a várt darabszámú tulajdonság alap érték lenne megadva if (classAbilities.Count != expectedAbilityCount) { throw new ArgumentException($"Character class definition '{characterClassDefinition.Code}' has {classAbilities.Count} ability base value definitions, but should have {expectedAbilityCount}."); } int abilityValueSum = 0; // leellenőrizzük, h minden tulajdonságra legyen megadva a kaszt specifikus alap érték foreach (var ability in await abilityRepo.All(null, cancellationToken)) { if (!classAbilities.TryGetValue(ability.Code, out var classAbilityBaseValue)) { throw new ArgumentException($"Ability base of '{ability.Code}' is missing from character class definition '{characterClassDefinition.Code}'."); } if ((classAbilityBaseValue < 6) || (classAbilityBaseValue > 10)) { throw new ArgumentOutOfRangeException($"Value '{classAbilityBaseValue}' of class ability '{ability.Code}' in character class definition '{characterClassDefinition.Code}' is out of range. Valid values are > 5 and < 11."); } abilityValueSum += classAbilityBaseValue; } // leellenőrizzük, hogy a class definícióban tényleg 80 tulajdonság pontot osztottak-e szét if (abilityValueSum != 80) { throw new ArgumentOutOfRangeException($"Sum of class ability base values '{abilityValueSum}' in character class definition '{characterClassDefinition.Code}' must equal to 80."); } }
public virtual IEnumerable <TEntity> All() { return(_readOnlyRepository.All()); }
public virtual IEnumerable <TEntity> All(bool @readonly = false) { return(@readonly ? _readOnlyRepository.All() : _repository.All()); }