/// <inheritdoc />
        public override async Task <IList <Claim> > GetClaimsAsync(TUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            user.ThrowIfNull(nameof(user));
            var userClaims = await UserClaimsRecord.GetClaimsAsync(user.Id);

            return(userClaims.Select(x => new Claim(x.ClaimType, x.ClaimValue)).ToList());
        }
 /// <inheritdoc />
 public override async Task AddClaimsAsync(TUser user, IEnumerable <Claim> claims,
                                           CancellationToken cancellationToken)
 {
     ThrowIfDisposed();
     user.ThrowIfNull(nameof(user));
     claims.ThrowIfNull(nameof(claims));
     UserClaims ??= (await UserClaimsRecord.GetClaimsAsync(user.Id)).ToList();
     foreach (var claim in claims)
     {
         UserClaims.Add(CreateUserClaim(user, claim));
     }
 }
 /// <inheritdoc />
 public override async Task RemoveClaimsAsync(TUser user, IEnumerable <Claim> claims,
                                              CancellationToken cancellationToken)
 {
     ThrowIfDisposed();
     user.ThrowIfNull(nameof(user));
     claims.ThrowIfNull(nameof(claims));
     UserClaims ??= (await UserClaimsRecord.GetClaimsAsync(user.Id)).ToList();
     foreach (var claim in claims)
     {
         var matchedClaims = UserClaims.Where(x =>
                                              x.UserId.Equals(user.Id) && x.ClaimType == claim.Type && x.ClaimValue == claim.Value);
         foreach (var matchedClaim in matchedClaims)
         {
             UserClaims.Remove(matchedClaim);
         }
     }
 }
        /// <inheritdoc />
        public override async Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim,
                                                     CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            user.ThrowIfNull(nameof(user));
            claim.ThrowIfNull(nameof(claim));
            newClaim.ThrowIfNull(nameof(newClaim));
            UserClaims ??= (await UserClaimsRecord.GetClaimsAsync(user.Id)).ToList();
            var matchedClaims = UserClaims.Where(x =>
                                                 x.UserId.Equals(user.Id) && x.ClaimType == claim.Type && x.ClaimValue == claim.Value);

            foreach (var matchedClaim in matchedClaims)
            {
                matchedClaim.ClaimValue = newClaim.Value;
                matchedClaim.ClaimType  = newClaim.Type;
            }
        }