/// <summary> /// Background method used to load the contents of the cache, initiated by the cache /// at the appropriate times /// </summary> /// <param name="cancellationToken">The cancellation token for use in cancelling the operation</param> /// <returns>The list to be placed into the cache</returns> private async Task <DisallowedFragmentList> GetListToCacheAsync(CancellationToken cancellationToken) { IDisallowedFragmentRepository repository; DisallowedFragmentList list; try { list = new DisallowedFragmentList(); repository = _repositoryFactory.CreateDisallowedFragmentRepository(); 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; } }
/// <summary> /// Create a complete, deep clone the list. /// Used by the underlying cache to avoid threading issues. /// </summary> /// <returns>A completely new instance of the list</returns> public object Clone() { DisallowedFragmentList list = new DisallowedFragmentList(); foreach (DisallowedFragmentInfo fragmentInfo in _list) { list.Add((DisallowedFragmentInfo)fragmentInfo.Clone()); } return(list); }