コード例 #1
0
        /// <summary>
        /// Background method used by the cache to load the list
        /// </summary>
        /// <param name="cancellationToken">The cancellation token used to manage timeout of the operation</param>
        /// <returns>The list that is to be cached</returns>
        private async Task <CharacterSetList> GetListToCacheAsync(CancellationToken cancellationToken)
        {
            ICharacterSetRepository repository;
            CharacterSetList        list;

            try
            {
                list       = new CharacterSetList();
                repository = _repositoryFactory.CreateCharacterSetRepository();
                try
                {
                    await list.LoadListAsync(repository).ConfigureAwait(false);
                }
                finally
                {
                    await DisposeRepositoryAsync(repository).ConfigureAwait(false);
                }
                return(list);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception during list retrieval");
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// Create a complete, disconnected clone of the list.
        /// Used by the underlying cache to avoid threading issues
        /// </summary>
        /// <returns>A complete, deep clone of the list</returns>
        public object Clone()
        {
            CharacterSetList list = new CharacterSetList();

            foreach (CharacterSetInfo setInfo in _list)
            {
                list.Add((CharacterSetInfo)setInfo.Clone());
            }

            return(list);
        }