System.Security.Claims.ClaimsPrincipal.FindAll C# (CSharp) Method

FindAll() public method

Retrieves a IEnumerable{Claim} where each claim is matched by .
Each ClaimsIdentity is called. ClaimsIdentity.FindAll.
if 'match' is null.
public FindAll ( Predicate match ) : IEnumerable
match Predicate The predicate that performs the matching logic.
return IEnumerable
        public virtual IEnumerable<Claim> FindAll(Predicate<Claim> match)
        {
            if (match == null)
            {
                throw new ArgumentNullException(nameof(match));
            }

            Contract.EndContractBlock();

            foreach (ClaimsIdentity identity in Identities)
            {
                if (identity != null)
                {
                    foreach (Claim claim in identity.FindAll(match))
                    {
                        yield return claim;
                    }
                }
            }
        }

Same methods

ClaimsPrincipal::FindAll ( string type ) : IEnumerable
ClaimsPrincipal::FindAll ( System match ) : System.Collections.Generic.IEnumerable
ClaimsPrincipal::FindAll ( string type ) : System.Collections.Generic.IEnumerable

Usage Example

 public static IEnumerable <string> GetClaimValues(
     this ClaimsPrincipal principal,
     string claimType)
 {
     return(principal.FindAll(claimType)
            .Select(x => x.Value));
 }
All Usage Examples Of System.Security.Claims.ClaimsPrincipal::FindAll