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

FindAll() public method

Retrieves a IEnumerable{Claim} where each Claim.Type equals type.
Each ClaimsIdentity is called. ClaimsIdentity.FindAll.
if 'type' is null.
public FindAll ( string type ) : IEnumerable
type string The type of the claim to match.
return IEnumerable
        public virtual IEnumerable<Claim> FindAll(string type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

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

Same methods

ClaimsPrincipal::FindAll ( Predicate match ) : 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