示例#1
0
        public static bool TryTakeUntil <T>(this IDropPoint <T> dropPoint, Predicate <T> check, ICollection <T> trail)
        {
            if (check == null)
            {
                throw new ArgumentNullException("check");
            }
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            if (trail == null)
            {
                throw new ArgumentNullException("trail");
            }
            T item;

back:
            if (dropPoint.TryTake(out item))
            {
                if (check(item))
                {
                    return(true);
                }
                trail.Add(item);
                goto back;
            }
            return(false);
        }
示例#2
0
        public static bool TryTakeUntil <T>(this IDropPoint <T> dropPoint, Predicate <T> check, out T item)
        {
            if (check == null)
            {
                throw new ArgumentNullException("check");
            }
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
back:
            if (dropPoint.TryTake(out item))
            {
                if (check(item))
                {
                    return(true);
                }
                else
                {
                    goto back;
                }
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        public static bool TryTakeAndIgnore <T>(this IDropPoint <T> dropPoint)
        {
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            T item;

            return(dropPoint.TryTake(out item));
        }
示例#4
0
        public static T TakeAndReturn <T>(this IDropPoint <T> dropPoint)
        {
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            T item;

            if (dropPoint.TryTake(out item))
            {
                return(item);
            }
            throw new InvalidOperationException();
        }