// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace Microsoft.AspNetCore.Authentication.OAuth.Claims { /// /// A collection of ClaimActions used when mapping user data to Claims. /// public class ClaimActionCollection : IEnumerable { private IList Actions { get; } = new List(); /// /// Remove all claim actions. /// public void Clear() => Actions.Clear(); /// /// Remove all claim actions for the given ClaimType. /// /// The ClaimType of maps to remove. public void Remove(string claimType) { var itemsToRemove = Actions.Where(map => string.Equals(claimType, map.ClaimType, StringComparison.OrdinalIgnoreCase)).ToList(); itemsToRemove.ForEach(map => Actions.Remove(map)); } /// /// Add a claim action to the collection. /// /// The claim action to add. public void Add(ClaimAction action) { Actions.Add(action); } public IEnumerator GetEnumerator() { return Actions.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return Actions.GetEnumerator(); } } }