예제 #1
0
        /// <summary>
        /// Read and unprotect cache data
        /// </summary>
        /// <returns>Unprotected cache data</returns>
        public byte[] ReadData(bool ignoreExceptions = true)
        {
            bool cacheFileExists = File.Exists(CacheFilePath);

            _logger.LogInformation($"ReadData Cache file exists '{cacheFileExists}'");

            byte[] data = null;
            try
            {
                _logger.LogInformation($"Reading Data");
                data = CacheAccessor.Read();
                _logger.LogInformation($"Got '{data?.Length}' bytes from file storage");
            }
            catch (Exception e)
            {
                _logger.LogError($"An exception was encountered while reading data from the {nameof(MsalCacheStorage)} : {e}");

                // It's unlikely that Clear will work, but try it anyway
                Clear();

                if (!ignoreExceptions)
                {
                    throw;
                }
            }

            return(data ?? new byte[0]);
        }
        /// <summary>
        /// Read and unprotect cache data
        /// </summary>
        /// <returns>Unprotected cache data</returns>
        public byte[] ReadData()
        {
            byte[] data = null;
            try
            {
                _logger.LogInformation($"Reading Data");
                data = CacheAccessor.Read();
                _logger.LogInformation($"Got '{data?.Length ?? 0}' bytes from file storage");
            }
            catch (Exception e)
            {
                _logger.LogError($"An exception was encountered while reading data from the {nameof(Storage)} : {e}");
                throw;
            }

            return(data ?? new byte[0]);
        }