protected async Task <Dictionary <string, ManagedToken> > GetManagedTokensAsync()
        {
            var cacheKey = await GetCacheKeyAsync();

            var protector = _dataProtectorAccessor.GetProtector(cacheKey);

            var json = await _cache.GetObjectFromJson <string>(cacheKey);

            Dictionary <string, ManagedToken> managedTokens = null;

            if (string.IsNullOrWhiteSpace(json))
            {
                managedTokens = new Dictionary <string, ManagedToken>();
                await UpsertManagedTokensAsync(managedTokens);

                return(managedTokens);
            }
            json = protector.Unprotect(json);

            var tokens = _serializer.Deserialize <Dictionary <string, ManagedToken> >(json);

            return(tokens);
        }
Beispiel #2
0
        protected Dictionary <string, ManagedToken> GetManagedTokens()
        {
            if (ManagedTokens != null)
            {
                return(ManagedTokens);
            }
            var cacheKey  = CacheKey;
            var protector = _dataProtectorAccessor.GetProtector(cacheKey);

            var json = Session.Get <string>(cacheKey);

            Dictionary <string, ManagedToken> managedTokens = null;

            if (string.IsNullOrWhiteSpace(json))
            {
                ManagedTokens = new Dictionary <string, ManagedToken>();
                UpsertManagedTokens(managedTokens);
                return(ManagedTokens);
            }
            json = protector.Unprotect(json);

            ManagedTokens = _serializer.Deserialize <Dictionary <string, ManagedToken> >(json);
            return(ManagedTokens);
        }