Пример #1
0
 /// <summary>
 /// Attempts to download/retrieve from cache the key.
 /// </summary>
 /// <param name="key">index of the file to retrieve</param>
 /// <returns>stream or null</returns>
 private SymbolStoreFile GetSymbolStoreFile(SymbolStoreKey key)
 {
     Debug.Assert(IsSymbolStoreEnabled);
     try
     {
         return(_symbolStore.GetFile(key, CancellationToken.None).GetAwaiter().GetResult());
     }
     catch (Exception ex) when(ex is UnauthorizedAccessException || ex is BadImageFormatException || ex is IOException)
     {
         Trace.TraceError("Exception: {0}", ex.ToString());
     }
     return(null);
 }
Пример #2
0
        /// <summary>
        /// Downloads the file or retrieves it from a cache from the symbol store chain.
        /// </summary>
        /// <param name="key">symbol index to retrieve</param>
        /// <param name="token">to cancel requests</param>
        /// <returns>file or null if not found</returns>
        public async Task <SymbolStoreFile> GetFile(SymbolStoreKey key, CancellationToken token)
        {
            SymbolStoreFile file = await GetFileInner(key, token);

            if (file == null)
            {
                if (_backingStore != null)
                {
                    file = await _backingStore.GetFile(key, token);

                    if (file != null)
                    {
                        await WriteFileInner(key, file);

                        // Reset stream to the beginning for next symbol store
                        file.Stream.Position = 0;
                    }
                }
            }
            return(file);
        }