示例#1
0
        public void Persist()
        {
            var cacheBits = _tokenCache.Serialize();

            Cache = new TokenEntity(userId, cacheBits, DateTime.UtcNow);
            _repository.InsertOrReplace(Cache);

            _tokenCache.HasStateChanged = false;
        }
示例#2
0
        public void Load()
        {
            var latestToken = _repository.GetAllTokensForUser(userId)
                              .OrderByDescending(a => a.LastWrite)
                              .FirstOrDefault();

            if (Cache == null || (latestToken != null && Cache.LastWrite < latestToken.LastWrite))
            {
                Cache = latestToken;
            }

            _tokenCache.Deserialize((Cache == null) ? null : Cache.CacheBits);
        }
示例#3
0
        public void InsertOrReplace(TokenEntity tokenEntity)
        {
            var tableOp = TableOperation.InsertOrReplace(tokenEntity);

            _cloudTable.ExecuteAsync(tableOp).Wait();
        }
示例#4
0
        public void Delete(TokenEntity tokenEntity)
        {
            var tableOp = TableOperation.Delete(tokenEntity);

            _cloudTable.ExecuteAsync(tableOp).Wait();
        }