Пример #1
0
 /// WARNING: if partitionKey is null, this API is slow as it loads all tokens, not just from 1 partition.
 /// It should only support external token caching, in the hope that the external token cache is partitioned.
 public virtual List <MsalAccountCacheItem> GetAllAccounts(string partitionKey = null, ICoreLogger requestlogger = null)
 {
     if (string.IsNullOrEmpty(partitionKey))
     {
         return(AccountCacheDictionary.SelectMany(dict => dict.Value).Select(kv => kv.Value).ToList());
     }
     else
     {
         AccountCacheDictionary.TryGetValue(partitionKey, out ConcurrentDictionary <string, MsalAccountCacheItem> partition);
         return(partition?.Select(kv => kv.Value)?.ToList() ?? CollectionHelpers.GetEmptyList <MsalAccountCacheItem>());
     }
 }
        /// <summary>
        /// WARNING: if partitonKey = null, this API is slow as it loads all tokens, not just from 1 partition.
        /// It should only support external token caching, in the hope that the external token cache is partitioned.
        /// </summary>
        public virtual List <MsalAccessTokenCacheItem> GetAllAccessTokens(string partitionKey = null, ICoreLogger requestlogger = null)
        {
            ICoreLogger logger = requestlogger ?? _logger;

            logger.Always($"[GetAllAccessTokens] Total number of cache partitions found while getting access tokens: {AccessTokenCacheDictionary.Count}");
            if (string.IsNullOrEmpty(partitionKey))
            {
                return(AccessTokenCacheDictionary.SelectMany(dict => dict.Value).Select(kv => kv.Value).ToList());
            }
            else
            {
                AccessTokenCacheDictionary.TryGetValue(partitionKey, out ConcurrentDictionary <string, MsalAccessTokenCacheItem> partition);
                return(partition?.Select(kv => kv.Value)?.ToList() ?? CollectionHelpers.GetEmptyList <MsalAccessTokenCacheItem>());
            }
        }
        public virtual List <MsalAccountCacheItem> GetAllAccounts(string partitionKey = null, ICoreLogger requestlogger = null)

        {
            return(CollectionHelpers.GetEmptyList <MsalAccountCacheItem>());
        }