public static TKey Get <TKey, TValue, TArgument>(this Dictionary <TKey, TValue> .KeyCollection collection, TArgument argument, CollectionPredicate <TKey, TArgument> predicate)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            return(CollectionsUtility.TryGet(collection.GetEnumerator(), argument, predicate, out TKey result) ? result : throw new CollectionValueNotFoundByArgumentException(argument));
        }
        public static bool TryGet <TKey, TValue, TArgument>(this Dictionary <TKey, TValue> .ValueCollection collection, TArgument argument, CollectionPredicate <TValue, TArgument> predicate, out TValue result)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            return(CollectionsUtility.TryGet(collection.GetEnumerator(), argument, predicate, out result));
        }
        public static TValue Get <TValue, TArgument>(this List <TValue> collection, TArgument argument, CollectionPredicate <TValue, TArgument> predicate)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            return(CollectionsUtility.TryGet(collection, argument, predicate, (list, index) => list[index], collection.Count, out TValue result) ? result : throw new CollectionValueNotFoundByArgumentException(argument));
        }
        public static bool TryGet <TValue, TArgument>(this IList <TValue> collection, TArgument argument, CollectionPredicate <TValue, TArgument> predicate, out TValue result)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            return(CollectionsUtility.TryGet(collection, argument, predicate, (list, index) => list[index], collection.Count, out result));
        }
Exemple #5
0
 public static TValue Get <TValue, TArgument>(this IEnumerable <TValue> collection, TArgument argument, CollectionPredicate <TValue, TArgument> predicate)
 {
     return(CollectionsUtility.TryGet(collection, argument, predicate, out TValue result) ? result : throw new CollectionValueNotFoundByArgumentException(argument));
 }
Exemple #6
0
 public static bool TryGet <TValue, TArgument>(this IEnumerable <TValue> collection, TArgument argument, CollectionPredicate <TValue, TArgument> predicate, out TValue result)
 {
     return(CollectionsUtility.TryGet(collection, argument, predicate, out result));
 }